📄 tfrqview2.m
字号:
function tfrqview(tfr,sig,t,method,p1,p2,p3,p4,p5);%TFRQVIEW Quick visualization of time-frequency representations.% TFRQVIEW(TFR,SIG,T,METHOD,P1,P2,P3,P4,P5) allows a quick % visualization of a time-frequency representation.%% TFR : time-frequency representation (MxN).% SIG : signal in time. If unavailable, put sig=[] as input% parameter. (default : []).% T : time instants (default : 1:N).% METHOD : name of chosen representation (default : 'TYPE1').% See the TFR* files for authorized names.% TYPE1 : the representation TFR goes in normalized% frequency from -0.5 to 0.5 ; % TYPE2 : the representation TFR goes in normalized% frequency from 0 to 0.5. % P1...P5 : optional parameters of the representation : run the % file TFRPARAM(METHOD) to know the meaning of P1..P5 % for your method. %% When you use the 'save' option in the main menu, you save all your% variables as well as two strings, TfrQView and TfrView, in a mat % file. If you load this file and do eval(TfrQView), you will restart% the display session under tfrqview ; if you do eval(TfrView), you% will obtain the exact layout of the screen you had when clicking on % the 'save' button. % % Example : % sig=fmsin(128); tfr=tfrwv(sig);% tfrqview(tfr,sig,1:128,'tfrwv');%% See also TFRVIEW, TFRSAVE, TFRPARAM.% F. Auger, September 1994, July 1995 % O. Lemoine, Oct 1995, May-July 1996.% Copyright (c) 1996 by CNRS (France).%% This program is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2 of the License, or% (at your option) any later version.%% This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this program; if not, write to the Free Software% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAcomp=computer; % Tests on the input argumentsif nargin<1, error('At least one parameter required');end[tfrrow,tfrcol]=size(tfr);if nargin==1, sig=[]; t=1:tfrcol; method='type1';elseif nargin==2, t=1:tfrcol; method='type1';elseif nargin==3, method='type1';end[trow,tcol] = size(t);if (trow~=1), error('T must only have one row'); end;if (tfrcol~=tcol), error('T must have as much elements as tfr has columns');end;method=upper(method);[Nsig,Ncol]=size(sig);if Ncol>2, error('SIG must have less than two columns');end% Computation of Nf2, the number of interresting points in frequencymethod=upper(method);if strcmp(method,'TFRWV' ) | strcmp(method,'TFRPWV' ) | ... strcmp(method,'TFRSPWV' ) | strcmp(method,'TFRCW' ) | ... strcmp(method,'TFRZAM' ) | strcmp(method,'TFRBJ' ) | ... strcmp(method,'TFRBUD' ) | strcmp(method,'TFRGRD' ) | ... strcmp(method,'TFRRSPWV') | strcmp(method,'TFRRPWV' ) | ... strcmp(method,'TFRRIDB' ) | strcmp(method,'TFRRIDH' ) | ... strcmp(method,'TFRRIDT' ) | strcmp(method,'TFRASPW' ) | ... strcmp(method,'TFRDFLA' ) | strcmp(method,'TFRSPAW' ) | ... strcmp(method,'TFRRIDBN') | strcmp(method,'TFRUNTER') | ... strcmp(method,'TFRBERT' ) | strcmp(method,'TFRSCALO') | ... strcmp(method,'TYPE2' ), Nf2=tfrrow;elseif strcmp(method,'TFRPMH' )| strcmp(method,'TFRRPMH' )| ... strcmp(method,'TFRSP' )| strcmp(method,'TFRRSP' )| ... strcmp(method,'TFRPPAGE')| strcmp(method,'TFRRPPAG')| ... strcmp(method,'TFRMHS' )| strcmp(method,'TFRRGAB' )| ... strcmp(method,'TFRMH' )| strcmp(method,'TFRMMCE' )| ... strcmp(method,'TFRRMSC' )| strcmp(method,'TFRPAGE' )| ... strcmp(method,'TFRGABOR')| strcmp(method,'TFRRI' )| ... strcmp(method,'TFRMSC' )| strcmp(method,'TYPE1' )| ... strcmp(method,'TFRSTFT' ), Nf2=tfrrow/2; else error('Unknown representation. Use type1 or type2');end;% Computation of freq (vector of frequency samples) if strcmp(method,'TFRASPW' ) | strcmp(method,'TFRSCALO') | ... strcmp(method,'TFRDFLA' ) | strcmp(method,'TFRSPAW' ) | ... strcmp(method,'TFRUNTER') | strcmp(method,'TFRBERT' ), freq=eval(['p',num2str(nargin-4)]); % last input argument is freqs.else freq=(0.5*(0:Nf2-1)/Nf2);end% Initialization of the current figurezoom off; clf; set(gcf,'Resize','On','NextPlot','Add');% Initialization of the variablesif exist('options.mat'), load optionselse threshold=5.0; linlogtfr=0; linlogspec=1; levelnumb=6; colmap=1; display=1; layout=1; iscolorbar=0; isgridsig=0; isgridspe=0; isgridtfr=0; issig=0; isspec=0;endchoice=4;Grid=1;displayold=1;fs=1.0;if ((layout>=2 & layout<=4) & isempty(sig)), layout=1;end% Initialization of the axes axcb = axes('Units','normal','Visible','off','Box','On');axsig = axes('Units','normal','Visible','off','Box','On');axspec = axes('Units','normal','Visible','off','Box','On');axtfr = axes('Units','normal','Visible','off','Box','On');if comp(1:2)=='PC', set(axsig ,'fontsize',10); set(axspec,'fontsize',10); set(axtfr ,'fontsize',10); endset(gcf,'UserData',[axcb axsig axspec axtfr]);% Test of analycityif ~isempty(sig), for k=1:Ncol, spec(:,k)=abs(fft(sig(min(t):max(t),k))).^2; Nsp=length(spec); spec1=sum(spec(1:round(Nsp/2),k)); spec2=sum(spec(round(Nsp/2)+1:Nsp,k)); if spec2>spec1/10, disp('Be careful : the signal is not analytic!'); end endend% Test of realityif (Ncol==2 & ~isreal(tfr)), disp('Cross distribution. As the result is complex, we display the real part.'); tfr=real(tfr);endwhile choice~=12, axes(axtfr); % The current axis is the tfr axis if (display~=7 & choice~=2 & choice~=3 & choice<8), % Call to tfrview linlog=linlogtfr+2*linlogspec; if choice==4, access=3; else access=1; end state=issig+2*iscolorbar; isgrid=isgridsig+2*isgridspe+4*isgridtfr; param = [display,linlog,threshold,levelnumb,Nf2,layout,access,state,fs,isgrid]; map=colormap; if (nargin<=4), tfrview(tfr,sig,t,method,param,map); elseif (nargin==5), tfrview(tfr,sig,t,method,param,map,p1); elseif (nargin==6), tfrview(tfr,sig,t,method,param,map,p1,p2); elseif (nargin==7), tfrview(tfr,sig,t,method,param,map,p1,p2,p3); elseif (nargin==8), tfrview(tfr,sig,t,method,param,map,p1,p2,p3,p4); elseif (nargin==9), tfrview(tfr,sig,t,method,param,map,p1,p2,p3,p4,p5); end; elseif (display==7), % keep in mind the last value of display display=displayold; end if (linlogtfr==0), % Lin/log scale of the tfr linlogstr='Change to a logarithmic scale'; else linlogstr='Change to a linear scale'; end; % Main menu choice=menu ('TFRQVIEW MENU :',... 'Change the display mode',... 'Change the display layout',... 'Change the color map',... 'Change the sampling frequency',... 'Change the threshold',... linlogstr,... 'Change the number of levels',... 'Grid',... 'Save',... 'Save options',... 'Print',... 'Close'); if ((choice==9 | choice==11) & comp(1:2)~='PC'), if exist('workdir.mat'), load workdir; else Path=pwd; str1=[' The current directory is ',Path]; disp(str1); disp(''); continue=0; while continue==0, continue=1; str2=' Name of the directory (with full path) on which the files will be saved : '; disp(str2); PathWorkDir=input(' > ','s'); if (exist(PathWorkDir)~=2), rep=input(' This directory doesn''t exist. Do you want to create it (y/n) ? ','s'); if upper(rep)=='Y', eval(['!mkdir ',PathWorkDir]); else continue=0; end end end if PathWorkDir(length(PathWorkDir))~='/', PathWorkDir=[PathWorkDir,'/']; end save workdir PathWorkDir; end end if (choice==1), % Change the display mode display=menu('DISPLAY MODE :',... 'Contour',... 'Imagesc',... 'Pcolor',... 'Surf',... 'Mesh',... 'Cancel'); elseif (choice==2), % Change the display layout layoutold=layout; indlo=1; layout=1; while layout~=6, % While not close if ~iscolorbar, colorbarstr='Add a color bar'; else colorbarstr='Remove the color bar'; end if ~linlogspec, specstr='TFR + Spectrum (linear)'; tfrsstr='TFR + Signal + Spectrum (linear)'; else specstr='TFR + Spectrum (logarithmic)'; tfrsstr='TFR + Signal + Spectrum (logarithmic)'; end layout=menu('DISPLAY LAYOUT :',... 'Time-Frequency Representation',... 'TFR + Signal ',... specstr,... tfrsstr,... colorbarstr,... 'Close'); if (layout==3|layout==4), linlogspec=1-linlogspec; end if ((layout>=2 & layout<=4) & isempty(sig)), disp('Impossible action : the signal is unavailable');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -