%%% Section 1.4 %%% State-Space modeling clear close all X = [0;1]; dt = 0.1; A = [1 dt; 0 1]; B = [dt.^2/2;dt]; m = 2; %u = T = 10; for i=1:(T/dt) X(:,i+1) = A*X(:,i);% + B*round(rand)./m end figure(1) plot([0:dt:T],X) legend('position','velocity') xlabel('time [sec]') ylabel('meters, m/s') %ylim([-.1,1.1]) X = [0;1]; for i=1:(T/dt) X(:,i+1) = A*X(:,i) + B*round(rand)./m; end figure(2) plot([0:dt:T],X) legend('position','velocity') xlabel('time [sec]') ylabel('meters, m/s')