%clear all clear all %conversion: mph2mpersec = 0.44704; %m/sec mpersec2mph = 1/mph2mpersec; m = 1300; %kg b = 42926.2; %N/volt a = 150.91; %30.17; % N/m^2 s^2 v_0 = 60*mph2mpersec; %m/s theta_0 = a*v_0^2/b; %volt %more constants p= 2*a*v_0/m; k = b/m; %PI controller - previously designed kp = 0.01; ki = 0.4341; % reference signal for the true velocity v r_prime_0 = v_0; r_prime_1 = 65*mph2mpersec; sim('car_nonlinear_closedloop'); figure plot(tout,v*mpersec2mph); %you'll see intial performance is very poor, that's because the linear %controller is always being used while the assumptionfor linearity is being %horribly violated in the first few seconds. It is remarkable that it works %at all. % But, when the speed settles down to 60 mph, when the second step command % of 65 mph comes at t = 10 seconds, the linear controller does a pretty good job.