function retval = interfere (canalt,canali) if (canalt==canali) retval = 1.0; else if (canalt==canali+1||canalt==canali-1) retval = 0.77; else if (canalt==canali+2||canalt==canali-2) retval = 0.54; else if (canalt==canali+3||canalt==canali-3) retval = 0.32; else if (canalt==canali+4||canalt==canali-4) retval = 0.09; else retval = 0.0; endif endif endif endif endif endfunction powert=dlmread("tabela_power.txt"); timet=dlmread("tabela_time.txt"); chant=dlmread("tabela_channel.txt"); usert=dlmread("tabela_user.txt"); canal=str2num(argv(){1}); nome=argv(){2}; interferencia(1)=0; for itime=2:length(timet) timet(itime)=timet(itime)-timet(1); endfor timet(1)=0; for itime=1:length(timet) timet(itime)=timet(itime)/1; endfor for itime=1:length(timet) if (usert(itime,2)==0) usert(itime,2) = power(10,-95/10); else usert(itime,2) = power(10,usert(itime,2)/10); endif endfor for itime=1:length(timet) interferencia(itime)=0; for ichan=1:length(chant(itime,:)) if (powert(itime,ichan)==0) powert(itime,ichan) = power(10,-95/10); else powert(itime,ichan) = power(10,powert(itime,ichan)/10); endif interferencia(itime)=interferencia(itime)+interfere(canal,chant(itime,ichan))*powert(itime,ichan); endfor endfor for ichan=1:length(chant(1,:)) temp(ichan)=max(chant(:,ichan)); endfor for itime=1:length(timet) for ichan=1:length(chant(itime,:)) if (chant(itime,ichan)==0) chant(itime,ichan)=temp(ichan); endif endfor endfor for itime=1:length(timet) rssi(itime)=usert(itime,2)/(interferencia(itime)+power(10,-95/10)); rssi(itime)=log10(rssi(itime))*10; endfor snir=[ "images/", nome, "_snir.png"]; plot(timet,rssi,'b--','linewidth',3); xlabel("Tempo (s)","fontsize",15); ylabel("SINR (dB)","fontsize",15); print('-dpng',snir); fid = fopen("tabela_essid.txt",'r'); legenda=fgetl(fid); legendb=strsplit(legenda,"\t"); canalt=canal*ones(length(chant(:,1)),1); hold off; newplot(); hold on; maxp=max(max(powert)); minp=min(min(powert)); for ichan=1:length(chant(1,:)) corcanal=0; potencia=0; for itime=1:length(timet) corcanal=corcanal+[chant(itime,ichan)/14 abs(chant(itime,ichan)-7)/14 (14-chant(itime,ichan))/14]; potencia=potencia+powert(itime,ichan); endfor corcanal=corcanal/length(timet); potencia=potencia/length(timet); corcanal=0.2*rand(1,3)+0.7*corcanal+[0.1 0.1 0.1]*(potencia-minp)/(maxp-minp); plot3(timet,chant(:,ichan),log10(powert(:,ichan))*10,'color',corcanal,'linewidth',2); endfor plot3(timet,canalt(:),log10(usert(:,2))*10,'color',[1 0.2 1],'linewidth',3); xlabel("Tempo (s)","fontsize",15); zlabel("Potencia (dBm)","fontsize",15); legend(legendb,"location", "eastoutside"); legend('show'); gcapos=get(gca,'position'); set(gca,'position',gcapos.*[1 1 0.6 1]); drawnow(); power=[ "images/", nome, "_power.png"]; print('-dpng',"-S1440,800",'-tight',power); set(gca,'position',gcapos);