CatchMe_SystemID - for k = 1:Kmax-1 Z_hat(k+1) =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
% CatchMe_SystemID.m % load Result_0_Preview Ball_pos Aim_pos Ball_0 = Ball_pos; Aim_0 = Aim_pos; load Result_Pnt3_Preview Ball_pos Aim_pos Ball_p3 = Ball_pos; Aim_p3 = Aim_pos; B Kmax = length(Ball_0) K = 1:Kmax; figure(3) subplot(2,1,1); plot(K,Ball_0,K,Aim_0); grid; subplot(2,1,2); plot(K,Ball_p3,K,Aim_p3); grid; t % An example of analysis % Zero preview data from 400 to 750 looks consistent U = Ball_0(401:700)'; Y = Aim_0(401:700)'; n = length(U); U %-------------------------------------------------------------- % Use a 1st order dynamic model y(k+1) = -a*y(k) + b*u(k) + c Z = Y(2:n); M = [-Y(1:n-1) U(1:n-1) ones(n-1,1)]; Theta = (M'*M)\M'*Z; % LSE Estimate of the model parameters a_hat = Theta(1), b_hat = Theta(2), c_hat = Theta(3) J0 = sum((Z-M*Theta)'*(Z-M*Theta)); % Reconstruct Aim using the estimated model parameters Z_hat(1) = Aim_0(1);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for k = 1:Kmax-1 Z_hat(k+1) = -a_hat*Z_hat(k) + b_hat*Ball_0(k) + c_hat; end figure(4); subplot(2,1,1); plot(K,Ball_0, K,Aim_0, K,Z_hat); grid; title('Model y(k+1) = -a*y(k) + b*u(k) + c'); t % ----------------------------------------% Use a DELAYED 1st order dynamic model y(k+1) = -a*y(k) + b*u(k-nd) + c nd = 20 Z = Y(20+2:n); M = [-Y(20+1:n-1) U(1:n-1-nd) ones(n-1-nd,1)]; Theta = (M'*M)\M'*Z; % LSE Estimate of the model parameters a_hat = Theta(1), b_hat = Theta(2), c_hat = Theta(3) J20 = sum((Z-M*Theta)'*(Z-M*Theta)); % Reconstruct Aim using the estimated model parameters Z_hat(1:nd) = Aim_0(1:nd); for k = 1:Kmax-1-nd Z_hat(k+1+nd) = -a_hat*Z_hat(k+nd) + b_hat*Ball_0(k) + c_hat; end e subplot(2,1,2); plot(K,Ball_0, K,Aim_0, K,Z_hat); grid; title('Model y(k+1) = -a*y(k) + b*u(k-nd) + c'); t figure(5) plot([0 20],[J0 J20],'r*'); axis([0 50 min(J0,J20)*0.9 max(J0,J20)*1.1]); p p...
View Full Document

This note was uploaded on 04/17/2011 for the course SYS 635 taught by Professor Re during the Spring '11 term at Albany College of Pharmacy and Health Sciences.

Page1 / 2

CatchMe_SystemID - for k = 1:Kmax-1 Z_hat(k+1) =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online