190 likes | 326 Views
背景設定. %% The matlab homework by FL TAI , M93860011 %% Neural Network Toolbox. Version 4.0.2 (R13SP1) 27-Dec-2002 %% the command: help nnet %% newlind for cosine function time = 0:0.025:5; %time start 0 to 5 sec, step:0.025 T=cos(time*4*pi); % the regular is 2 pi
E N D
背景設定 • %% The matlab homework by FL TAI , M93860011 • %% Neural Network Toolbox. Version 4.0.2 (R13SP1) 27-Dec-2002 • %% the command: help nnet • %% newlind for cosine function • time = 0:0.025:5; %time start 0 to 5 sec, step:0.025 • T=cos(time*4*pi); % the regular is 2 pi • Q=length(T); % calculate the number of T
迴圈 • P=zeros(5,Q); %set P = Zeros array , 5 - Q matrix, all element is zero • %% rewrite the P matrix, P is the netline input • for n=1:10 ; % recurrence circle from 1 to 10 • P(n,(n+1):Q)=T(1,1:(Q-n)); • % set P , row 1 :2-Q element = T row1 1:Q-1element • end; % end the recurrence
類神經處理 • net=newlind(P,T); • % Linear layers are often used as adaptive filters • % for signal processing and prediction. • a=sim(net,P); % calculate the net output by P
畫圖 • figure (1); • plot(time,a,time,T,'*'),ylabel('Amplitude (gal)'),xlabel('Time (s)'),grid on,title('Neural Network --cosine,input=10'); • % compare the sim and raw data
運算 • [xa,ia]=max(abs(a(1,1:201))); %find the first abs maximum error position of matrix a, must be 1 • ma=(ia-1)*0.025; % ma is the first time arrive the maximum error • disp(xa); %first maximum error value • disp(ma); %ma= the time of first maximum error value • text(3,1.2,'max net-sim y :1.0192gal'); %1.0192 = disp(xa) • text(3,1.4,'max net-sim x: 0.025sec'); %0.025 = disp(ma)
畫圖 • figure (2); • e=T-a; • plot(time,e),ylabel('error (gal)'),xlabel('Time (s)'),grid on,title('Neural Network --cosine,input=10' ); %plot the error signal • % plot the error line
計算誤差 • [xe,ie]=min(abs(e(1,1:201))); %find the first abs minimum error position of matrix e, • %% x =abs minimum value, must be 0, i = the column position • me=(ie-1)*0.025; % me is the first time arrive the minimum error • disp(xe); %first minimum error value, disp on monitor • disp(me); %me= the time of first minimum error value • text(3,0.9,'min error y : 0.00011083 gal'); %0.00011083 = disp(xe) • text(3,1.1,'min error x: 2.525sec'); %2.525 = disp(me)
背景設定 • %% The matlab homework by FL TAI , M93860011 • %% Neural Network Toolbox. Version 4.0.2 (R13SP1) 27-Dec-2002%% the command: help nnet%% newlind for seismogram time = 25:0.05:45; %0.005 tran 0.05 • load ch080t2545.txt % the 921 earthquake data of chy080, only the U(+) sequence% the raw data is select from 25 sec to 45 sec ,T=ch080(5000:9000,1)';% and devide 10 ,c=T(1:10:4001)'; form 1 to 4001 step 10 • T=ch080t2545(:,1)'; % set T is a row array • Q=length(T);
迴圈 • P=zeros(10,Q); • for n=1:10 ; % recurrence circle from 1 to 5P(n,(n+1):Q)=T(1,1:(Q-n)); % set P , row 1 :2-Q element = T row1 1:Q-1element end; % end the recurrence
類神經處理 • net=newlind(P,T);% Linear layers are often used as adaptive filters% for signal processing and prediction.a=sim(net,P); % calculate the net output by P
畫圖 • figure (1);plot(time,a,time,T,'*'),ylabel('Amplitude (gal)'),xlabel('Time (s)'),grid on,title('Neural Network --921 shy080 U(+) , input=10'); • figure (2);e=T-a;plot(time,e),ylabel('error (gal)'),xlabel('Time (s)'),grid on,title('Neural Network --921 shy080 U(+) , input=10');
計算誤差 • me=mean(abs(e(1,1:401))); %find the first abs mean error position of matrix e, disp(me); %me= the time of first mean error valuetext(40,210,'mean error y: 28.8327 gal'); • %2.525 = disp(me)
time = 1:1:1460; load pressure.txt T=pressure(:,1)'; Q=length(T); P=zeros(1460,Q); for n=1:1460 ; P(n,(n+1):Q)=T(1,1:(Q-n)); end; net=newlind(P,T); a=sim(net,P); figure (1); plot(time,a,time,T,'*'),ylabel('pressure (mb)'),xlabel('Time (day)'),grid on,title('pressure , input=1460 days'); figure (2); e=T-a; plot(time,e),ylabel('error (mb)'),xlabel('Time (day)'),grid on,title('pressure , input=1460 days'); 範例:92-95年最高氣壓資料處理