function h=osaplot(fDC, vMod, nlink, pos, Log, LineProp) % A function to make an optical spectrum analyzer type plot % h=osaplot(fDC, vMod, nlink, pos) % fDC: The output of sweep or tickle % % vMod: The RF vector used for the Optickle model. % % nlink (optional): The link number at which the electric fields are evaluated. % (Default = 1) % % pos (optional): Position index. Only varid if the fDC is an output of % sweep(). (Default = 1) % % Log (optional): If Log is true, the Y-axis of the power plot will be log. % (Default = 1) % % LineProp % Assign default values to the optional arguments. try a=nlink; catch nlink=1; end try a=pos; catch pos=1; end try a=Log; catch Log=1; end try a=LineProp; catch LineProp='-ob'; end [vModEng,Scale,Unit]=engunits(vMod); ax1=subplot(2,1,1); ax2=subplot(2,1,2); if length(size(fDC)) == 3 carrierPhase=angle(fDC(nlink,find(vMod==0),pos)); stem(ax1,vModEng,abs(fDC(nlink,:,pos)).^2, LineProp); stem(ax2,vModEng,180/pi*angle(fDC(nlink,:,pos)*exp(-i*carrierPhase)), LineProp); else carrierPhase=angle(fDC(nlink,find(vMod==0))); stem(ax1,vModEng,abs(fDC(nlink,:)).^2, LineProp); stem(ax2,vModEng,180/pi*angle(fDC(nlink,:)*exp(-i*carrierPhase)), LineProp); end if Log set(ax1, 'YScale','log'); end set(ax1,'XTickMode','manual'); set(ax1,'XTick',vModEng); set(ax1,'XGrid','off'); set(ax1,'YGrid','on'); ylabel(ax1,'Power [W]'); set(ax2,'XTickMode','manual'); set(ax2,'XTick',vModEng); set(ax2,'YTick',[-180:45:180]); set(ax2,'XGrid','off'); set(ax2,'YGrid','on'); xlabel(ax2,['Frequency [',Unit,'Hz]']); ylabel(ax2,'Phase [deg.]'); set(gcf, 'Position',[1 1 900 700]); h=[ax1,ax2];