function [xtruth,z] = sect_4_3_gen_xz(Phi, H, Q, Psi, Q_nu, N) % % Generates the truth (xtruth) and measurements (z) when the % measurement noise is time-correlated. % % Inputs: % N = the number of measurements to process (xtruth has then one more sample corresponding to \hat{x](0)) % % 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. % %----- wkm1 = sqrt(Q)*randn([1,N]); % the process noise nk = zeros([1,N]); % storage for the measurement noise for k=1:(N-1) nk(k+1) = Psi * nk(k) + sqrt(Q_nu)*randn(); end % 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;