function [xtruth,z] = sect_4_4_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 = mvnrnd( [0;0], Q, N ).'; % the process noise of size [N,2] nk = zeros([2,N]); % storage for the measurement noise for k=1:(N-1) nk(:,k+1) = Psi * nk(:,k) + mvnrnd( [0;0], Q_nu ).'; end % Generate the *true* state history xtruth = zeros(2,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;