Home > chronux_0.5 > plots > plotvector.m

plotvector

PURPOSE ^

Function to plot a frequency dependent vector X. If error bars are specified in Xerr,

SYNOPSIS ^

function plotvector(X,f,plt,Xerr)

DESCRIPTION ^

 Function to plot a frequency dependent vector X. If error bars are specified in Xerr,
 it also plots them. Xerr can either contain upper and lower confidence intervals 
 on X, or simply a theoretical confidence level (for the coherence). Used
 to plot the spectrum and coherency.
 Usage: plotvector(X,f,plt,Xerr)
 Inputs:
 X: input vector as a function of frequency (f), see third argument
 f: f axis grid for plot. Default. [1:length(X)]
 plt: 'l' for log, 'n' for no log.
 Xerr: lower and upper confidence intervals for X1: lower/upper x f. Or
       simply a single number specifying an f-independent confidence
       level.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plotvector(X,f,plt,Xerr)
0002 % Function to plot a frequency dependent vector X. If error bars are specified in Xerr,
0003 % it also plots them. Xerr can either contain upper and lower confidence intervals
0004 % on X, or simply a theoretical confidence level (for the coherence). Used
0005 % to plot the spectrum and coherency.
0006 % Usage: plotvector(X,f,plt,Xerr)
0007 % Inputs:
0008 % X: input vector as a function of frequency (f), see third argument
0009 % f: f axis grid for plot. Default. [1:length(X)]
0010 % plt: 'l' for log, 'n' for no log.
0011 % Xerr: lower and upper confidence intervals for X1: lower/upper x f. Or
0012 %       simply a single number specifying an f-independent confidence
0013 %       level.
0014 if nargin < 1; error('Need data'); end;
0015 N=length(X); 
0016 if nargin < 2;
0017     f=1:N;
0018 end;
0019 if length(f)~=N; error('frequencies and data have incompatible lengths'); end;
0020 if nargin < 3;
0021     plt='l';
0022 end;
0023 if strcmp(plt,'l');
0024     X=10*log10(X);
0025     if nargin ==4; Xerr=10*log10(Xerr); end;
0026 end;
0027 
0028 if nargin < 4;
0029     plot(f,X);
0030 else
0031     if length(Xerr)==1;
0032        plot(f,X); 
0033        line(get(gca,'xlim'),[Xerr,Xerr],'Color','r');
0034     else
0035        plot(f,X); 
0036        hold on; plot(f,Xerr(1,:),'g'); plot(f,Xerr(2,:),'g'); 
0037     end
0038 end
0039 xlabel('f');
0040 if strcmp(plt,'l'); ylabel('10*log10(X)'); else ylabel('X'); end;
0041 
0042

Generated on Tue 16-Aug-2005 21:33:45 by m2html © 2003