% part 6 of the mini project: % Prabir Barooah, March 20, 2009 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; % the closed loop transfer function from r to y P = tf(k,[1 p]); C = tf([kp ki],[1 0]); H_ry = feedback(series(P,C),1); time = [0:0.01:10]'; y = step(H_ry,time); scale = max(abs(y))/v_0 % so the step size required to make max|y/v_0| = 0.1 is step_size_threshold = 0.1/scale %now plot the response to a step of this size to check visually that indeed %|y/v| (at some time t) becomes greater than 0.1 u = step_size_threshold *ones(length(time),1); y_with_large_step = lsim(H_ry,u,time); figure; plot(time,y_with_large_step/v_0); ylabel('y/v_0'); xlabel('time (sec)');