error matlab

4
cla update_model; add_spectrum; HVSR(fHV>fc1 & fHV<fc2)=HVSR(min(find(fHV>fc1))); %Disregard HVSR between fc1 and fc2 fmin=max(max(fHV(1),f(1)),f1); fmax=min(min(fHV(end),f(end)),f2); for i=1:10 for j=1:6 rbhnd=['hnd.' 'rb' num2str(i) num2str(j)]; rbhnd=eval(rbhnd); fixm(i,j)=get(rbhnd,'value'); end end hold off rand('state',sum(100*clock)); nrand=str2num(get(hnd.edit95,'string')); erbest=9999999999.; %fM=f(find(HVobs==max(HVobs))); %freq. where obs. HVSR has a maximum %w=1./(abs(f-fM)+1); vsfit=[]; vpfit=[]; hfit=[]; qsfit=[]; qpfit=[]; rofit=[]; daffit=[]; vs1=vs'; vp1=vp'; h1=h'; ro1=ro'; qp1=qp'; qs1=qs'; vpbest=vp; vsbest=vs; robest=ro; hbest=h; qpbest=qp; qsbest=qs; amp_racunaj_SP f=f(find(f>=fmin & f<=fmax)); a=a(find(f>=fmin & f<=fmax)); HVobs=interp1(fHV,HVSR,f,'linear','extrap')'; [fFS,FSraw]=FourierSpectrum(magn,delt,dept,rock); %Compute theoretical Fourier spectrum for target earthquake (see Setup) %eksp=1; %defined in setup.mat ww=HVobs; ww(ww<1)=1; if get(hnd.checkbox5,'value')==1; display('log-weights') weight=(ww.^eksp)./(f'.^1); %Weight is large around large values of observed HVSR else weight=(ww.^eksp); %No logarithmic weighting end sweight=cumsum(weight); sweight=sweight(end); pctvp=str2double(get(hnd.edit84,'string'))/100;

Upload: andi-tenri-awali-wildana

Post on 12-Jul-2016

18 views

Category:

Documents


0 download

DESCRIPTION

MATLAB

TRANSCRIPT

Page 1: Error Matlab

claupdate_model;add_spectrum; HVSR(fHV>fc1 & fHV<fc2)=HVSR(min(find(fHV>fc1))); %Disregard HVSR between fc1 and fc2 fmin=max(max(fHV(1),f(1)),f1);fmax=min(min(fHV(end),f(end)),f2); for i=1:10 for j=1:6 rbhnd=['hnd.' 'rb' num2str(i) num2str(j)]; rbhnd=eval(rbhnd); fixm(i,j)=get(rbhnd,'value'); endend hold offrand('state',sum(100*clock)); nrand=str2num(get(hnd.edit95,'string'));erbest=9999999999.;%fM=f(find(HVobs==max(HVobs))); %freq. where obs. HVSR has a maximum%w=1./(abs(f-fM)+1);vsfit=[]; vpfit=[]; hfit=[]; qsfit=[]; qpfit=[]; rofit=[]; daffit=[];vs1=vs'; vp1=vp'; h1=h'; ro1=ro'; qp1=qp'; qs1=qs';vpbest=vp; vsbest=vs; robest=ro; hbest=h; qpbest=qp; qsbest=qs;amp_racunaj_SPf=f(find(f>=fmin & f<=fmax));a=a(find(f>=fmin & f<=fmax));HVobs=interp1(fHV,HVSR,f,'linear','extrap')'; [fFS,FSraw]=FourierSpectrum(magn,delt,dept,rock); %Compute theoretical Fourier spectrum for target earthquake (see Setup) %eksp=1; %defined in setup.matww=HVobs; ww(ww<1)=1;if get(hnd.checkbox5,'value')==1; display('log-weights') weight=(ww.^eksp)./(f'.^1); %Weight is large around large values of observed HVSRelse weight=(ww.^eksp); %No logarithmic weightingendsweight=cumsum(weight); sweight=sweight(end);pctvp=str2double(get(hnd.edit84,'string'))/100;pctvs=str2double(get(hnd.edit128,'string'))/100;pctr=str2num(get(hnd.edit90,'string'))/100;pcth=str2num(get(hnd.edit92,'string'))/100;pctq=str2num(get(hnd.edit94,'string'))/100;Dvp=str2num(get(hnd.edit83,'string'))/100;Dvs=str2num(get(hnd.edit127,'string'))/100;Dr=str2num(get(hnd.edit89,'string'))/100;Dh=str2num(get(hnd.edit91,'string'))/100;Dq=str2num(get(hnd.edit93,'string'))/100;

Page 2: Error Matlab

if isempty(Dvp), Dvp=inf; set(hnd.edit83,'string','inf'); endif isempty(Dvs), Dvs=inf; set(hnd.edit127,'string','inf'); endif isempty(Dh), Dh=inf; set(hnd.edit89,'string','inf'); endif isempty(Dr), Dr=inf; set(hnd.edit91,'string','inf'); endif isempty(Dq), Dq=inf; set(hnd.edit93,'string','inf'); endpct=pctfit/100; %Defined in setup.mat for ijk=1:nrand if ijk>1, var_rnd=1; else var_rnd=0; end %Set the random perturbation mode amp_racunaj_SP a=a(find(f>=fmin & f<=fmax)); if sorp==3 aswave=aswave(find(f>=fmin & f<=fmax)); else aswave=a; end f=f(find(f>=fmin & f<=fmax)); er1=cumsum( ((a-HVobs).^2).*weight ); er=er1(end)./sweight; if er<erbest, erbest=er; modelbest=model; abest=a; vpbest=vp1; vsbest=vs1; robest=ro1; hbest=h1; qpbest=qp1; qsbest=qs1; semilogx(f,a,f,HVobs); drawnow, end FS=interp1(fFS,FSraw,f,'linear','extrap')'; FS(f>25)=0; FS(f<0.1)=0; %FS is defined only for 0.1<=f<=25 Hz aFS=FS.*aswave; rms_eqk=sqrt( mean( FS(FS>0).^2) ); rms_amp=sqrt( mean(aFS(FS>0).^2) ); DAF=rms_amp/rms_eqk; set(hnd.edit95,'string',num2str(nrand-ijk)); vsfit=[vsfit;vs1 er]; vpfit=[vpfit;vp1 er]; hfit =[hfit;h1 er]; qsfit=[qsfit;qs1 er]; qpfit=[qpfit;qp1 er]; rofit=[rofit;ro1 er]; daffit=[daffit;DAF er]; drawnow;endhmsg=msgbox('Wait, saving results!');dlmwrite([workdir '\Vs.fit'],vsfit,' '); %workdir is defined in modelHVSR.m, a direktory in whic modelHVSR.m residesdlmwrite([workdir '\H.fit'], hfit,' ');dlmwrite([workdir '\Vp.fit'],vpfit,' ');dlmwrite([workdir '\Qs.fit'],qsfit,' ');dlmwrite([workdir '\Ro.fit'],rofit,' ');dlmwrite([workdir '\Qp.fit'],qpfit,' ');dlmwrite([workdir '\DAF.fit'],daffit,' ');save fit.mat vpfit vsfit hfit rofit qpfit qsfit daffit fixmclose(hmsg) var_rnd=0; %Turn off the random perturbation modeclasemilogx(f,abest,'k','linewidth',2)

Page 3: Error Matlab

hold on; set(hnd.checkbox3,'value',1);semilogx(f,HVobs,'r','linewidth',2) set(hnd.edit95,'string',num2str(nrand));display('Best model found')modelbestdisplay('Starting model')model0update_modelamp_racunaj_SP %Racuna AMP za osnovni model i crta gahold off; set(hnd.checkbox3,'value',0); grid on axes(hax2)claaxis onset(gca,'xtick',[]); set(gca,'ytick',[]);box onmodelbest(nsloj,4)=999; model0(nsloj,4)=999;modelbest(nsloj,5)=999; model0(nsloj,5)=999;modelbest(nsloj,6)=999; model0(nsloj,6)=999;mod1=sprintf(' %4.0f %4.0f %4.2f %5.1f %3.0f %3.0f\n',modelbest');mod2=sprintf(' %4.0f %4.0f %4.2f %5.1f %3.0f %3.0f\n',model0');head=' Vp Vs rho D Qp Qs'; text(0.0,0.90,head,'color','k','fontsize',11,'verticalalignment','top','fontname','Courier New');text(0.0,0.75,mod1,'color','k','fontsize',11,'verticalalignment','top','fontname','Courier New'); text(0.60,0.90,head,'color','b','fontsize',11,'verticalalignment','top','fontname','Courier New');text(0.60,0.75,mod2,'color','b','fontsize',11,'verticalalignment','top','fontname','Courier New');axes(hax1);set_flim; modelbest(:,1)=round(modelbest(:,1));modelbest(:,2)=round(modelbest(:,2));modelbest(:,3)=round(modelbest(:,3)*100)/100;modelbest(:,4)=round(modelbest(:,4)*10)/10;modelbest(:,5)=round(modelbest(:,5));modelbest(:,6)=round(modelbest(:,6)); set(hnd.pushbutton15,'visible','on')set(hnd.pushbutton16,'visible','on')dlmwrite([workdir '\Best.mod'],modelbest,' ');dlmwrite([workdir '\ampspektar.mod'],model0,' ');ijk=0;

Page 4: Error Matlab