function phaserDiagram(fDC, vMod, nlink, pos, sbIdxes) % Make phaser diagrams to show the fields at a link % h=phaserDiagram(fDC, vMod, nlink, pos, sbIdxes) % 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) % % Assign default values to the optional arguments. try a=nlink; catch nlink=1; end try a=pos; catch pos=[1]; end nSidebands = (numel(vMod)-1)/2; try a=sbIdxes; catch sbIdxes=[1:nSidebands]; end [vModEng,Scale,Unit]=engunits(vMod); SbNames = vModEng(nSidebands+2:end); %Plot arrangement maxCols = 7; nPlots = numel(pos); nRows = floor(nPlots/maxCols-1/(2*maxCols)) + 1; if nRows > 1 nCols = maxCols; else nCols = nPlots; end % Determine the scaling factors normFactCarrier= max(abs(fDC(nlink, nSidebands+1, :))); for ii = 1:numel(sbIdxes) idx = sbIdxes(ii); Lower = abs(fDC(nlink, nSidebands+1-idx,:)); Upper = abs(fDC(nlink, nSidebands+1+idx,:)); normFactSb(ii) = max(max(Upper),max(Lower)); end % Determine the phase standard. phaseOrigin = fDC(nlink, nSidebands+1, round(nPlots/2)); phaseOrigin = phaseOrigin/abs(phaseOrigin); phaseOrigin = 1; for ii=1:numel(pos) p=pos(ii); %Prepare axes ax=subplot(nRows,nCols,p); axes(ax); line([-1,1],[0,0],'Color','k'); line([0,0],[-1,1],'Color','k'); %Plot Carrier Carrier= i*fDC(nlink, nSidebands+1,p)*conj(phaseOrigin)/normFactCarrier; line([0,real(Carrier)],[0,imag(Carrier)],'Color','g','LineWidth',2); %Plot Sidebands for ii = 1:numel(sbIdxes) idx = sbIdxes(ii); Lower = fDC(nlink, nSidebands+1-idx,p); Upper = fDC(nlink, nSidebands+1+idx,p); Lower = i*Lower*conj(phaseOrigin)/normFactSb(ii)/2; Upper = i*Upper*conj(phaseOrigin)/normFactSb(ii)/2; line([0,real(Lower)],[0,imag(Lower)],'Color','b','LineWidth',2); line([0,real(Upper)],[0,imag(Upper)],'Color','r','LineWidth',2); end set(ax, 'XLim',[-1,1]) set(ax, 'YLim',[-1,1]) end set(gcf, 'Position',[100,800,260*nCols,180*nRows])