Home > wafo > papers > wafodemo > wafofig.m

wafofig

PURPOSE ^

callback implementing functions of WAFODEMO

SYNOPSIS ^

wafofig(ix)

DESCRIPTION ^

  WAFOFIG  callback implementing functions of WAFODEMO

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

001 function wafofig(ix)
002 % WAFOFIG  callback implementing functions of WAFODEMO
003 global WAFOFIGNUM 
004 if isempty(WAFOFIGNUM)
005   disp('You must start wafodemo in order to run this script')
006   return
007 end
008 Nfigs=10; % 
009 global wafomenulabels
010 
011 
012 switch ix
013   case -1,  % change default settings
014     WAFOFIGNUM=0;
015     changesettingsmenu; % local function
016     
017   case -2, % make all figures
018     WAFOFIGNUM=Nfigs;
019     wafoinit
020     cfig=gcf;
021     for iy=1:Nfigs,
022       figure(cfig-1+iy)
023       figname = ['wafofig',num2str(iy)];
024        %clc; home;
025       help(figname);
026       eval(figname); 
027       drawnow;
028     end
029     for iy=1:Nfigs,
030       figure(cfig-1+iy)
031       figname = ['wafofig',num2str(iy)];
032       help(figname);
033     end
034    case -3, % select a figure
035      if isempty(wafomenulabels)| WAFOFIGNUM==0, wafoinit; end
036      iy = menu('Choose a figure',wafomenulabels{:},'Cancel')
037      if ~isempty(iy) & (1 <= iy & iy <=Nfigs) ,
038        WAFOFIGNUM = iy;
039        
040        figname = ['wafofig',num2str(iy)];
041        
042        clc; home; help(figname);
043        eval(figname);
044        clc; home; help(figname);
045        drawnow;
046      end
047      
048    otherwise
049      disp('Unknown Input argument to wafofig') 
050      disp(sprintf('num =%g',ix))
051 end
052      
053    
054 function changesettingsmenu
055 %
056 %
057 
058 global WAFOFIGNUM 
059 % Define Globals used (that the user also  might change)
060 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
061 global Fs                          % sampling frequency for torsethaugen
062 global St Hm0 Tp                   % torsethaugen output, input Fig 2
063 global xt Nsim Iseed               % spec2sdat output , input    Fig1
064 global Ste L                       % dat2spec output, input      Fig2
065 global fTt fTte u Np nit speed     % spec2thpdf output, input    Fig3  
066 global Tt rate                     % dat2wa output, input        Fig3
067 global ma mb sp                    % spreading input             Fig4
068 global fTcfAc NNp Nh Nnit Nspeed   % spec2thpdf output, input    Fig5  
069 global NVcf NHd Nrate              % dat2steep output, input     Fig5
070 global fTcfAcTc JNp Jh Jnit Jspeed      % spec2thpdf output, input    Fig6  
071 global JTcf JAc Jind Jrate         % dat2steep output, input     Fig6
072 global kdeTt kernel hs L2          % kdebin input: kernel, smoothing  (Fig3)
073 global kdeVcfHd Nkernel Nhs NL2    % and transformation  parameter,   (Fig5)
074 global kdeTcfAcTc Jkernel Jhs JL2  % respectively                     (Fig6)
075 
076 WAFOFIGNUM=0;
077 wafoinit % initialize global variables
078         % and put them into the cellarray of default values 
079 def=cell(5,1);
080 def{1}={Fs Hm0 Tp sp ma mb};
081 def{2}={Nsim Iseed L };
082 def{3}={rate kernel hs L2 u Np nit speed};
083 def{4}={Nrate Nkernel Nhs NL2 NNp Nnit Nspeed};
084 def{5}={Jrate Jkernel Jhs JL2 JNp Jnit Jspeed};
085 
086 % Convert def to strdef containing only strings
087 strdef=def;
088 for ix=1:length(def)
089   for iy=1:length(def{ix})
090     if isnumeric(def{ix}{iy})
091       strdef{ix}{iy}=num2str(def{ix}{iy});
092     end
093   end
094 end
095 
096 lineNo=1;
097 title1='Change Spectral parameters fig1-4 (See torsethaugen, spreading)';
098 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
099 prompt1 ={ ...
100 'Enter sampling frequency, Fs. (Hz):',...
101 'Enter significant wave height, Hm0:',...
102 'Enter peak period, Tp:',...
103 'Enter spreading parameter, sp:', ...
104 'Enter spreading shape parameter, ma):',...
105 'Enter spreading shape parameter, mb):'};
106 answer=inputdlg(prompt1,title1,lineNo,strdef{1},'on');
107 
108 Na=length(answer);
109 if Na>0
110   ind1=zeros(1,Na); % index to changed variables
111   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
112   ind2=find(ind1); 
113   for ix=ind2(:).',
114     answer{ix}=str2num(answer{ix});
115     if (isempty(answer{ix})|answer{ix}==def{1}{ix}), ind1(ix)=0; else, def{1}{ix}=answer{ix}; end
116   end
117   ind2=find(ind1>0); 
118   if any(ind2) % set variables  that must be calculated again to empty.
119     if any(ind2<=3), % fig1,2,3
120       St=[];xt=[];Ste=[]; Tt=[]; 
121       fTt=[]; fTte=[];    kdeTt=[];
122     end 
123     [Fs, Hm0, Tp, sp, ma, mb]=deal(def{1}{:});
124   end
125 end
126 
127 
128 title2='Change Simulation parameters fig1-3 (See spec2sdat, dat2spec, dat2wa)';
129 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130 prompt2 ={ ...
131 'Enter length of simulated time series. (Nsim):',...
132 'Enter seed for random number generator (iseed):',...
133 'Enter maximum lag size of the window function (L).:'};
134 answer=inputdlg(prompt2,title2,lineNo,strdef{2},'on');
135 
136 Na=length(answer);
137 if Na>0
138   ind1=zeros(1,Na); % index to changed variables
139   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
140   ind2=find(ind1); 
141   for ix=ind2(:).',
142     answer{ix}=str2num(answer{ix});
143     if (isempty(answer{ix})|answer{ix}==def{2}{ix}), ind1(ix)=0; else, def{2}{ix}=answer{ix}; end
144   end
145   ind2=find(ind1>0); 
146   if any(ind2) % set variables  that must be calculated again to empty.
147     Ste=[];fTte=[];
148     if any(ind2<=2), % fig1,2,3
149       xt=[]; Tt=[]; 
150       kdeTt=[];
151     end
152     [Nsim, Iseed, L]=deal(def{2}{:});
153   end
154 end
155 
156 title3='Change distribution fitting parameters fig3 (See dat2wa kdebin spec2thpdf)';
157 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158 prompt3 ={ ...
159 'Enter interpolation rate before extracting Tt from data. (rate):',...
160 'Enter name for kernel:',...
161 'Enter smoothing parameter hs (default 1D optimal value using hns):',...
162 'Enter transformation parameter (L2):',...
163 'Enter reference level defining Tt (u):',...
164 'Enter number of points for which the theoretical pdf is computed (Np<100):', ......
165 'Enter nit (-2 and 0,1,...,9):',....
166 'Enter speed (1,2,...,9):'};
167 
168 answer=inputdlg(prompt3,title3,lineNo,strdef{3},'on');
169 
170 Na=length(answer);
171 if Na>0
172   ind1=zeros(1,Na); % index to changed variables
173   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
174   ind2=find(ind1); 
175   for ix=ind2(:).',
176     if ix~=2
177       answer{ix}=str2num(answer{ix});
178       if (isempty(answer{ix})|answer{ix}==def{3}{ix}), ind1(ix)=0; else,def{3}{ix}=answer{ix}; end
179     else
180       if (strcmpi(answer{ix},def{3}{ix})), ind1(ix)=0; else,def{3}{ix}=answer{ix}; end
181     end
182     
183   end
184   ind2=find(ind1>0); 
185   if any(ind2) % set variables  that must be calculated again to empty.
186     if any(ind2<=5), % fig3
187      
188       kdeTt=[];
189       if any(ind2==1), Tt=[];  end
190     end
191     if any(ind2>=5), % fig3
192        fTt=[]; fTte=[];
193     end
194     [rate kernel hs L2 u Np nit speed]=deal(def{3}{:});
195   end
196 end
197 
198 
199 title4='Change distribution fitting parameters fig5 (See dat2steep kdebin spec2thpdf)';
200 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201 prompt4 ={ ...
202 'Enter interpolation rate before extracting parameters from data. (rate):',...
203 'Enter name for kernel:',...
204 'Enter smoothing parameter vector hs (default 1D optimal value using hns):',...
205 'Enter transformation parameter vector (L2):',...
206 'Enter number of points for time axis for which theoretical pdf is computed (Np<100):',...
207 'Enter nit (-2 and 0,1,...,9):',...
208 'Enter speed (1,2,...,9):'};
209 answer=inputdlg(prompt4,title4,lineNo,strdef{4},'on');
210 
211 Na=length(answer);
212 if Na>0
213   ind1=zeros(1,Na); % index to changed variables
214   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
215   ind2=find(ind1); 
216   for ix=ind2(:).',
217     if ix~=2
218       answer{ix}=str2num(answer{ix});
219       if (isempty(answer{ix})|answer{ix}==def{3}{ix}), ind1(ix)=0; else,def{3}{ix}=answer{ix}; end
220     else
221       if (strcmpi(answer{ix},def{3}{ix})), ind1(ix)=0; else,def{3}{ix}=answer{ix}; end
222     end
223     
224   end
225   ind2=find(ind1>0); 
226   if any(ind2) % set variables  that must be calculated again to empty.
227     if any(ind2<=4), % fig5
228       kdeVcfHd=[];
229       if any(ind2==1) ,NVcf=[],NHd=[];end
230     end
231     if any(ind2>=4), % fig5
232        fTcfAc=[]; 
233     end
234     [Nrate Nkernel Nhs NL2 NNp Nnit Nspeed]=deal(def{4}{:});
235   end
236 end
237 
238 
239 title5='Change distribution fitting parameters fig6 (See dat2steep kdebin spec2thpdf)';
240 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
241 prompt5 ={ ...
242 'Enter interpolation rate before extracting parameters from data. (rate):',...
243 'Enter name for kernel:',...
244 'Enter smoothing parameter vector hs (default 1D optimal value using hns):',...
245 'Enter transformation parameter vector (L2):',...
246 'Enter number of points for time axis for which theoretical pdf is computed (Np<100):',...
247 'Enter nit (-2 and 0,1,...,9):',...
248 'Enter speed (1,2,...,9):'};
249 answer=inputdlg(prompt5,title5,lineNo,strdef{5},'on');
250 
251 Na=length(answer);
252 if Na>0
253   ind1=zeros(1,Na); % index to changed variables
254   for ix=1:Na, ind1(ix)=~isempty(answer(ix));  end
255   ind2=find(ind1); 
256   for ix=ind2(:).',
257     if ix~=2
258       answer{ix}=str2num(answer{ix});
259       if (isempty(answer{ix})|answer{ix}==def{3}{ix}), ind1(ix)=0; else,def{3}{ix}=answer{ix}; end
260     else
261       if (strcmpi(answer{ix},def{3}{ix})), ind1(ix)=0; else,def{3}{ix}=answer{ix}; end
262     end
263     
264   end
265   ind2=find(ind1>0); 
266   if any(ind2) % set variables  that must be calculated again to empty.
267     if any(ind2<=4), % fig6
268       kdeTcfAcTc=[];
269       if any(ind2==1) ,JTcf=[],JAc=[];end
270     end
271     if any(ind2>=4), % fig6
272        fTcfAcTc=[]; 
273     end
274     [Jrate Jkernel Jhs JL2 JNp Jnit Jspeed]=deal(def{5}{:});
275   end
276 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