Home > wafo > papers > rec > recfig.m

recfig

PURPOSE ^

callback implementing functions of RecDemo

SYNOPSIS ^

recfig(ix)

DESCRIPTION ^

  RECFIG  callback implementing functions of RecDemo

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

001 function recfig(ix)
002 % RECFIG  callback implementing functions of RecDemo
003 global RECFIGNUM 
004 if isempty(RECFIGNUM)
005   disp('You must start recdemo in order to run this script')
006   return
007 end
008 Nfigs=13;
009 global recmenulabels
010 
011 
012 switch ix
013   case -1,  % change default settings
014     RECFIGNUM=0;
015     changesettingsmenu; % local function    
016   case -2, % make all figures
017     RECFIGNUM=Nfigs;
018     recinit
019     cfig=gcf;
020     for iy=1:Nfigs,
021       figure(cfig-1+iy)
022       figname = ['recfig',num2str(iy)];
023       %clc; home;
024       help(figname);
025       eval(figname);
026       drawnow;
027     end
028     for iy=1:Nfigs,
029       figure(cfig-1+iy)
030       figname = ['recfig',num2str(iy)];
031       help(figname);
032     end
033    case -3, % select a figure
034      if isempty(recmenulabels), recinit; end
035      iy = menu('Choose a figure',recmenulabels{:},'Cancel');
036      if ~isempty(iy) & (1 <= iy & iy <=Nfigs) ,
037        RECFIGNUM = iy;
038        recinit
039        figname = ['recfig',num2str(iy)];
040        
041        clc; home; help(figname);
042        eval(figname);
043        drawnow;
044      end
045    otherwise
046      disp('Unknown Input argument to recfig') 
047      disp(sprintf('num =%g',ix))
048 end
049      
050    
051 function changesettingsmenu
052 % Local function implementing 
053 %
054 
055 global RECFIGNUM  recfilename xn xr ft2 fkde V H
056 %Reconstruction parameters
057 global zcrit dcrit ddcrit Nsim L csm1 csm2 
058 % distribution fitting parameters
059 global rate  res noverlap CSMA CSMB
060 % kernel density estimation parameters
061 global kernel hs L2
062 
063 RECFIGNUM=0;
064 recinit % initialize global variables
065         % and put them into the cellarray of default values 
066 def=cell(3,1);
067 def{1}={zcrit,dcrit,ddcrit,Nsim,L,csm1,csm2};
068 def{2}={rate,res,noverlap,CSMA,CSMB};
069 def{3}={kernel,hs,L2};
070 % Convert def to strdef containing only strings
071 strdef=def;
072 for ix=1:length(def)
073   for iy=1:length(def{ix})
074     if isnumeric(def{ix}{iy})
075       strdef{ix}{iy}=num2str(def{ix}{iy});
076     end
077   end
078 end
079 lineNo=1;
080 
081 answer=inputdlg({'Enter name of data set to reconstruct:'},'Change data set',lineNo,{recfilename},'on');
082 Na=length(answer);
083 if Na>0
084   if (~strcmp(deblank(answer{ix}),deblank(recfilename))),
085     recfilename = answer{ix};
086     xn=[];
087     xr=[];V=[];H=[];phat=[];sphat=[]; % all must be calculated again
088     ft2=[];fkde=[];inds=[];
089     sphat=[]; ft2=[];           
090     phat=[];V=[];H=[]; fkde=[];
091   end
092 end  
093 
094 title1='Change Reconstruction parameters (See findoutliers, reconstruct)';
095 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
096 prompt1 ={ ...
097 'Enter critical distance between consecutive points. (zcrit):',...
098 'Enter critical distance of diff(xn(:,2)) (dcrit):',...
099 'Enter critical distance of diff(xn(:,2),2) (ddcrit):',...
100 'Enter maximum number of iterations of the reconstruction (Nsim):', ...
101 'Enter lag size of the window function (default the lag where  ACF<2 stdev, maximum 200):',...
102 'Enter a value for csm1 which defines smoothing  of log(crossing intensity):',...
103 'Enter a value for csm2 which defines smoothing  of transformation g:'};
104 answer=inputdlg(prompt1,title1,lineNo,strdef{1},'on');
105 Na=length(answer);
106 if Na>0
107   ind1=zeros(1,Na); % index to changed variables
108   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
109   ind2=find(ind1>0); 
110   for ix=ind2(:).',
111     answer{ix}=str2num(answer{ix});
112     if (isempty(answer{ix})|answer{ix}==def{1}{ix}), ind1(ix)=0; else, def{1}{ix}=answer{ix}; end
113   end
114   ind2=find(ind1>0); 
115   if any(ind2) % set variables  that must be calculated again to empty.
116     xr=[];V=[];H=[];phat=[];sphat=[]; % some or all of def{1} is changed
117     ft2=[];fkde=[];                      
118     if (any(ind2<4)),inds=[];end      % some or all of zcrit,dcrit or ddcrit is changed
119     [zcrit,dcrit,ddcrit,Nsim,L,csm1,csm2]=deal(def{1}{:});
120   end
121 end
122 
123 
124 
125 title2='Change distribution fitting parameters (See dat2steep dist2dfit dist2dsmfun2)';
126 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
127 prompt2 ={...
128 'Enter interpolation rate of the data before extracting data (rate):',...
129 'Enter a value for res  which defines the bin size used in the conditional fitting:',...
130 'Enter a value for noverlap which defines the number of groups overlapping in the conditional fitting:',...
131 'Enter a value for CSMA which defines smoothing of Weibull scale parameter:',...
132 'Enter a value for CSMB which defines smoothing of Weibull shape parameter:'};
133 answer=inputdlg(prompt2,title2,lineNo,strdef{2},'on');    
134 Na=length(answer);
135 if Na>0
136   ind1=zeros(1,Na); % index to changed variables
137   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
138   ind2=find(ind1>0);
139   for ix=ind2(:).',
140     answer{ix}=str2num(answer{ix});
141     if (isempty(answer{ix})|answer{ix}==def{2}{ix}), ind1(ix)=0; else, def{2}{ix}=answer{ix}; end
142   end
143   ind2=find(ind1>0); 
144   if any(ind2) % set variables  that must be calculated again to empty.
145     sphat=[]; ft2=[];                % some or all of def{2} is changed
146     if (any(ind2<2)), phat=[];V=[];H=[]; fkde=[];end % rate is changed
147     if (any(ind2==2 | ind2==3)), phat=[];        end % res or  noverlap  changed
148     [rate,res,noverlap,CSMA,CSMB]=deal(def{2}{:});
149   end
150 end
151 
152 
153 
154 title3='Change Kernel Density Estimation parameters (See kdebin)';
155 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156 prompt3={...
157 'Enter name for kernel:',...
158 'Enter a smoothing parameter vector for hs (default 1D optimal value using hns):',...
159 'Enter vector of transformation parameters (L2):'};
160 answer=inputdlg(prompt3,title3,lineNo,strdef{3},'on');    
161 Na=length(answer);
162 if Na>0,
163   ind1=zeros(1,Na); % index to changed variables
164   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
165   ind2=find(ind1>0);
166   for ix=ind2(:).',
167     if (ix~=1), % ix==1 ==> kernel string nothing to do
168       answer{ix}=str2num(answer{ix});
169       if (isempty(answer{ix})|answer{ix}==def{3}{ix}), ind1(ix)=0; else, def{3}{ix}=answer{ix}; end
170     else
171       if (strcmpi(answer{ix},def{3}{ix})), ind1(ix)=0; else, def{3}{ix}=answer{ix}; end
172     end
173   end
174   ind2=find(ind1>0); 
175   if any(ind2) % set variables  that must be calculated again to empty.
176     fkde=[]; % some or all of def{3} is changed    
177     [kernel,hs,L2]=deal(def{3}{:});
178   end
179 end

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003