Home > chronux > spectral_analysis > plots > plot_matrix.m

plot_matrix

PURPOSE ^

Function to plot a time-frequency matrix X. Time and frequency axes are in t and f.

SYNOPSIS ^

function plot_matrix(X,t,f,plt,Xerr)

DESCRIPTION ^

 Function to plot a time-frequency matrix X. Time and frequency axes are in t and f.
 If error bars are specified in Xerr,
 it also plots them. Xerr contains upper and lower confidence intervals 
 on X. 
 Usage: plot_matrix(X,t,f,plt,Xerr)
 Inputs:
 X: input vector as a function of time and frequency (t x f)
 t: t axis grid for plot. Default [1:size(X,1)]
 f: f axis grid for plot. Default. [1:size(X,2)]
 plt: 'l' for log, 'n' for no log.
 Xerr: lower and upper confidence intervals for X1: lower/upper x t x f.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plot_matrix(X,t,f,plt,Xerr)
0002 % Function to plot a time-frequency matrix X. Time and frequency axes are in t and f.
0003 % If error bars are specified in Xerr,
0004 % it also plots them. Xerr contains upper and lower confidence intervals
0005 % on X.
0006 % Usage: plot_matrix(X,t,f,plt,Xerr)
0007 % Inputs:
0008 % X: input vector as a function of time and frequency (t x f)
0009 % t: t axis grid for plot. Default [1:size(X,1)]
0010 % f: f axis grid for plot. Default. [1:size(X,2)]
0011 % plt: 'l' for log, 'n' for no log.
0012 % Xerr: lower and upper confidence intervals for X1: lower/upper x t x f.
0013 if nargin < 1; error('Need data'); end;
0014 [NT,NF]=size(X);
0015 if nargin < 2;
0016     t=1:NT;
0017 end;
0018 if nargin < 3;
0019     f=1:NF;
0020 end;
0021 if length(f)~=NF || length(t)~=NT; error('axes grid and data have incompatible lengths'); end;
0022 if nargin < 4 || isempty(plt);
0023     plt='l';
0024 end;
0025 if strcmp(plt,'l');
0026     X=10*log10(X);
0027     if nargin ==5; Xerr=10*log10(Xerr); end;
0028 end;
0029 
0030 if nargin < 5;
0031    imagesc(t,f,X');axis xy; colorbar; title('Spectrogram');
0032 else
0033    subplot(311); imagesc(t,f,squeeze(Xerr(1,:,:))'); axis xy; colorbar; title('Lower confidence');
0034    subplot(312); imagesc(t,f,X'); title('X');axis xy; colorbar;
0035    subplot(313); imagesc(t,f,squeeze(Xerr(2,:,:))'); axis xy; colorbar; title('Upper confidence');
0036 end;
0037 xlabel('t');ylabel('f');
0038

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005