% Example 8.12 % second order response % varying wn, zeta is constant % The user should remove the portions of the code that require a % toolbox that he or she does not have. % This portion of the code requires the Control Systems Toolbox. t = 0:.05:20; wn = .5; zeta = .4; num = wn^2; den = [1 2*zeta*wn wn^2]; y1 = step(num,den,t); wn = 1; num = wn^2; den = [1 2*zeta*wn wn^2]; y2 = step(num,den,t); wn = 2; num = wn^2; den = [1 2*zeta*wn wn^2]; y3 = step(num,den,t); plot(t,y1,'-',t,y2,'--',t,y3,'-.'); xlabel('Time (sec)') ylabel('y(t)') title('Second order step response, zeta = 0.4') % the following inserts a legend hold on plot([9 11],[.5 .5],[9 11],[.4 .4],'--',[9 11],[.3 .3],'-.'); text(12,.5,'wn = 0.5') text(12,.4,'wn = 1') text(12,.3,'wn = 2') hold off % The following portion requires the Symbolic Math Toolbox. syms Y y s zeta = 0.4; wn = 0.5; % rerun with different values of wn Y = wn^2/(s^3+2*zeta*wn*s^2+wn^2*s); y = ilaplace(Y); ezplot(y,[0 20]) axis([0 20 0 1.5]) xlabel('Time (sec)') ylabel('y(t)') title('Second order step response, zeta = 0.4')