function plotResult(ex,result,modemno,side,ftype,fax,namestr) %% =========================================================================== %plotResult - Plot the resulting transmission curves % % Parameter: ex The experiment parameters % Parameter: result The experiment result structure % Parameter: modemno The modem number to plot % Parameter: side Indicate if we are looking at NT or LT side % Parameter: ftype The type of frequency axis ('log','Linear') % Parameter: fax.min The min frequency to plot % Parameter: fax.max The max frequency to plot % Parameter: namestr Prefix name % % Example(s): % figure; % plotResult(ex,result,2,'NT'); % % Algorithmic details: % % Reference: %% =========================================================================== %% =========================================================================== % Copyright (C): % 1998-1999 by Telia Research AB, Lulea, Sweden; % 2000-2009 by Forschungszentrum Telekommunikation Wien, Austria; % All rights reserved. % Project : FTW's xDSLsimu % Author(s) : Daniel Bengtsson (Daniel.J.Bengtsson@Telia.se) % : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % : Bo Engstrom (bosse@upzide.com) % : Petr Kadlec (kadlec@ftw.at) % % CVS: $Id: plotResult.m 752 2009-01-02 13:03:52Z tono $ %% =========================================================================== % Change History % 1998-12-17 (ToNo) Created % 1998-12-21 (ToNo) Restructured calculations % 1998-12-22 (ToNo) Made use of getTFplan to clean up things % 1999-01-14 (ToNo) Added support for Log axis and specially % defined frequency axes; fixed title bug for ADSL % 1999-02-25 (ToNo) Generlized list (tfplist) handling % 1999-03-01 (DaB) Updated to correct addition bug % 1999-03-03 (DaB) Renamed bg to Alien % 1999-08-19 (DaB) updated for new tfplan struct % 1999-10-01 (DaB) Rewritten for new ex struct % 2000-05-02 (ToNo) Added legend to curves. Removed a mixup % in plotting Tot_LT instead of Tot_NT % 2000-12-14 (GS) Added abs() for vectors to be plotted % 2001-06-21 (Bosse) Octave port % 2001-06-25 (Bosse) Added an extra title string % 2001-07-05 (ToNo) Now we support two-sided colored background noise % 2002-07-02 (Peka) Octave to Matlab port % 2002-07-23 (Peka) update of the figure setup % 2003-11-03 (ToNo) Lists now use cell arrays for both Octave and Matlab % 2005-01-12 (ToNo) Current octave do not handle legend correctly % 2005-10-25 (ToNo) Changed how we handle missing arguments % 2005-10-27 (ToNo) Cleaned up plotting differences octave/matlab % 2008-08-29 (ToNo) Made the title strings more informative % 2008-10-09 (ToNo) Made use of octave 3.0's matlab compatibility %% =========================================================================== % Check arguments if nargin<4, error('Not enough input arguments.'); end nores=length(result); if modemno>nores, error('No such modem.'); end if nargin<5 || isempty(ftype) % Default plot method is linear ftype = 'Linear'; end; if nargin<7, namestr=''; end dm=getDM(ex.tt.traffic,ex.param.modemlist); % Extract more information about the modem modemname = sprintf('%s (%s)',ex.tt.traffic{dm(modemno)}{3},result{modemno}.Modem.Name); modemLT = ex.tt.topology{result{modemno}.Modem.LT_Node}{3}; modemNT = ex.tt.topology{result{modemno}.Modem.NT_Node}{3}; % Do we need to define a min max point for the axis? if nargin<6 || isempty(fax) if strcmp(ftype,'Log'), fax.min=7e3; fax.max=30e6; else fax.max=0; for n=1:length(dm), x=result{n}; tfplan=getList(ex.tfplist,x.Modem.Name); tmp=max(... [tfplan.PSD.active.upstream tfplan.PSD.active.downstream])+1e6; fax.max=max(fax.max,tmp); fax.min=ex.param.frequency.min; end; end end %% =========================================================================== % Get hold of some global parameters f=ex.param.frequency.f; % Set up useful plot axis lowest=min([eval([ex.param.bgNoise.LT,';']) eval([ex.param.bgNoise.NT,';'])]); axvec=[fax.min fax.max lowest -40]; %% =========================================================================== % Now plot the selected curves % Plot it if onMatlab reset(gca); else % Can not use reset_cga as it resets subplot setup end set(gcf,'DefaultLineLineWidth',2); if strcmp(modemname(1:4),'VDSL'), % Fix for VDSL TDD y=result{modemno}; Tot_NT=y.NT.Tot_noise.down; Tot_LT=y.LT.Tot_noise.up; else y=result{modemno}; Tot_NT=y.NT.Tot_noise.up; Tot_LT=y.LT.Tot_noise.down; end; if strcmp(side,'LT') % Plot the LT side titlestr=sprintf('%s%s at the LT (%s) side',namestr,modemname,modemLT); y=result{modemno}; if strcmp(ftype,'Log') semilogx(f,10*log10(abs(y.LT.Rx_signal)),'-',... f,10*log10(abs(y.LT.Alien_noise)),'-',... f,10*log10(abs(Tot_LT)),'-') legend ('Rx;','Alien noise;','Total noise;',0); else % Linear scale plot(f,10*log10(abs(y.LT.Rx_signal)),'-',... f,10*log10(abs(y.LT.Alien_noise)),'-',... f,10*log10(abs(Tot_LT)),'-') legend ('Rx;','Alien noise;','Total noise;',1); end title(titlestr); axis(axvec); xlabel('Frequency[Hz]'); grid('on'); axis('on'); elseif strcmp(side,'NT'), % Plot the NT side titlestr=sprintf('%s%s at the NT (%s) side',namestr,modemname,modemNT); y=result{modemno}; if strcmp(ftype,'Log') semilogx(f,10*log10(abs(y.NT.Rx_signal)),'-',... f,10*log10(abs(y.NT.Alien_noise)),'-',... f,10*log10(abs(Tot_NT)),'-') legend ('Rx;','Alien noise;','Total noise;',0); else plot(f,10*log10(abs(y.NT.Rx_signal)),'-',... f,10*log10(abs(y.NT.Alien_noise)),'-',... f,10*log10(abs(Tot_NT)),'-') legend ('Rx;','Alien noise;','Total noise;',1); end title(titlestr); axis(axvec); xlabel('Frequency[Hz]'); grid('on'); axis('on'); else error('Side not recognized.'); end