function [xtruth,z] = sect_4_5_gen_xz(Phi, H, Q, R, 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;0], Q, N ).'; % the process noise of size [N,3] nk = mvnrnd( [0;0], R, N ).'; % Generate the *true* state history xtruth = zeros(3,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;