# ps5_soln - EE 482 Problem 21: Problem Set 5 Solutions -2- %...

This preview shows pages 1–10. Sign up to view the full content.

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

View Full Document
EE 482 Problem Set 5 Solutions -2- Problem 21: % EE 482 Spring 2008 % Problem Set 5, Problem 21 % load the measured data ym and xm: % ym(k) = m xm(k) + b load ps5_p21_data % construct the A matrix and b column vector A = [ xm' * xm, sum(xm); ... sum(xm), length(xm)]; b = [xm' * ym; sum(ym)]; % find the least squares estimate of m and b theta = inv(A) * b; % find the estimated value of y % y_est(k) = m_est xm(k) + b_est y_est = theta(1) * xm + theta(2); % plot the measured data and estimated line figure(1) plot(xm, y_est, 'g' , xm, ym, 'or' ) legend([ 'estimated line: m_{est} = ' ,num2str(theta(1), 3), ', ' , ... ' b_{est} = ' ,num2str(theta(2), 3)], ... 'measurement data' ) ylabel( 'y' ) xlabel( 'x' ) title( 'Problem Set 5, Problem 22' )

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

View Full Document

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

View Full Document

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

View Full Document
EE 482 Problem Set 5 Solutions -9- Problem 23: function [J, num_d, den_d, y_est] = find_LSE(y,u, n, m) % EE 482 Spring 2008 % Function to generate LSE N = length(y); % number of data {u(k), y(k)} data points % % Find batch least-squares estimate of theta for n, m % phi(k) = [y(k-1),,,,, y(k-n), u(k-n+m),. .. u(k-n)]'; n+m+1 by 1 col vector % theta = [-a(n-1),. ..,-a0, bm, . .. bo]'; n+m+1 by 1 col vector % Let % A = sum( phi(k) * phi'(k) ) form k = n to N; A is n+m+1 by n+m+1 matrix % b = sum( y(k) phi(k) ) from k = n to N; b is n+m+1 by 1 col vector % The batch least-squares estimate is %

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/23/2008 for the course EE 482 taught by Professor Schiano during the Spring '08 term at Pennsylvania State University, University Park.

### Page1 / 17

ps5_soln - EE 482 Problem 21: Problem Set 5 Solutions -2- %...

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

View Full Document
Ask a homework question - tutors are online