0001 function plotsigdiff(X1,X1err,X2,X2err,plt,t,f)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if nargin < 7; error('Need all arguments'); end;
0019 [T1,F1]=size(X1); [T2,F2]=size(X2);
0020 if T1~=T2 || F1~=F2;
0021 error('Arrays are incompatible');
0022 end;
0023 if F1==1 || F2==1;
0024 error('need row vector inputs');
0025 end;
0026 ystr='';
0027 if T1*T2==1,
0028 mask=zeros(1,F1);
0029 indx=find(X1err(1,:)>X2err(2,:) | X2err(1,:)>X1err(2,:));
0030 mask(indx)=1;
0031 if strcmp(plt,'l');
0032 X1=10*log10(X1); X2=10*log10(X2); X1err=10*log10(X1err); X2err=10*log10(X2err);
0033 ystr= ' dB';
0034 end;
0035 subplot(311); plot(f,X1,f,X1err(1,:),f,X1err(2,:));
0036 title('Spectrum 1');
0037 xlabel('f')
0038 ylabel(['S1' ystr]);
0039 subplot(312); plot(f,X2,f,X2err(1,:),f,X2err(2,:));
0040 title('Spectrum 2');
0041 xlabel('f')
0042 ylabel(['S2' ystr]);
0043 subplot(313); plot(f,mask.*(X1-X2));
0044 title('Difference where significant');
0045 xlabel('f')
0046 ylabel(['S1-S2' ystr]);
0047 else
0048 mask=zeros(T1,F1);
0049 for n=1:length(t);
0050 for m=1:length(f);
0051 if X1err(1,n,m)>X2err(2,n,m);
0052 mask(n,m)=1;
0053 elseif X2err(1,n,m)>X1err(2,n,m);
0054 mask(n,m)=1;
0055 end;
0056 end;
0057 end;
0058 if strcmp(plt,'l');
0059 X1=10*log10(X1);X2=10*log10(X2);
0060 ystr=' dB';
0061 end;
0062 subplot(311); imagesc(t,f,X1'); axis xy; colorbar;
0063 xlabel('f')
0064 ylabel(['S1' ystr]);
0065 subplot(312); imagesc(t,f,X2'); axis xy; colorbar;
0066 xlabel('f')
0067 ylabel(['S2' ystr]);
0068 subplot(313); imagesc(t,f,(mask.*(X1-X2))'); axis xy; colorbar
0069 xlabel('f')
0070 ylabel(['S1-S2' ystr]);
0071 end