function [xtruth,z] = sect_4_2_gen_xz(Phi, H, Q, M, R, N) % % Generates the truth (xtruth) and measurements (z) when the % disturbance noise and measurement noise are cross-correlated. % % 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. % %----- % Generate propagation and measurement noise for k=1:N EWN = [ Q, M; M, R ]; if( false ) C = chol(EWN); C = C'; U = randn( N, 2 ); U = U'; X = C * U; % thes are drawn from the nessesary dynamic noise and measurement noise distribution... cross correlated % check that the above statement is true EWN mean( X, 2 ) cov( X' ) else X = mvnrnd( [0;0], EWN, N ).'; end wkm1 = X(1,:); % the process noise nk = X(2,:); % the measurement noise % Generate the *true* state history xtruth = zeros(1,N+1); for k=1:N xtruth(k+1) = Phi*xtruth(k) + wkm1(k); end % Generate the measurements (off of the true state): z = H*xtruth(2:(N+1)) + nk;