function [xtruth,z_k] = sect_6_2_gen_xz(x_0, Phi, Gamma, u_k, Q, ref_pt_1, ref_pt_2, R, N) % % Generates the truth (xtruth) and measurements (z) for the specified nonlinear model. % % Inputs: % N = the number of measurements to process (xtruth has then one more sample corresponding to \hat{x](0)) % between the times t_0 and t_final. % % Checked: 2011-07-17 (error found in need to generate *non* linear measurements) % % 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. % %----- n = length(x_0); % Generate the *true* state history xtruth = zeros(n,N+1); xtruth(:,1) = x_0(:); % the initial condtion on the state for km1 = 1:N w = mvnrnd( zeros(1,n), Q ); xtruth(:,km1+1) = Phi * xtruth(:,km1) + Gamma * u_k + w(:); end % Generate the *nonlinear* measurements (off of the true state x(t)): z_k = zeros(n,N); for km1 = 1:N, [h,H] = sect_6_2_h_fn(xtruth(:,km1+1), ref_pt_1, ref_pt_2); z_k(:,km1) = h + mvnrnd( zeros(n,1), R, 1 ).'; end