% % Written by: % -- % John L. Weatherwax 2005-08-14 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clear; close all; clc; clear functions; Htilde = [ 0, 1; 3, 4 ]; Z1 = [ 0, 1, 7, 8, 5, 7, 9, 10, 6, 4 ]; Z1 = Z1(:); Z2 = [ 10, 7, 4, 5, 5, 3, 0, 2, 2, 4 ]; Z2 = Z2(:); Z = [ Z1, Z2 ]; % All two by one measurement vectors stacked on top of each other: T = Z'; Zstacked = T(:); nMeasurements = length(Z1); % Stack many copies of Htilde on top of each other H = []; for ii=1:nMeasurements, H = [ H; Htilde ]; end % If the true x is given then the pure measurements for all is then given by % H x and we want to pick x such that H x is a close to Zstacked as possible % in a least squares sense % xhat = ( H' * H ) \ ( H' * Zstacked ); figure; plot( Zstacked, 'bo' ); hold on; plot( H * xhat, 'xr' );