1.11 Display the response to a unit step of an under, critically, and over damped system

Problem: Obtain unit step response of the second order system given by the transfer function \[ H\left ( s\right ) =\frac {\omega _{n}^{2}}{s^{2}+2\xi \omega _{n}s+\omega _{n}^{2}}\] in order to illustrate the response when the system is over, under, and critically damped. use \(\omega _{n}=1\) and change \(\xi \) over a range of values that extends from under damped to over damped.

Mathematica

Clear["Global`*"]; 
Needs["PlotLegends`"] 
 
sys=TransferFunctionModel[w^2/(s^2+2*z*w*s+w^2),s]; 
zValues = Range[.2,1.2,.2]; 
fun = OutputResponse[sys/.{w->1,z->#}, UnitStep[t], 
       {t,0,20}]&/@zValues; 
 
Plot[Evaluate@Flatten@Table[fun[[i]], 
                         {i,1,Length[fun]}], 
   {t,0,20}, 
   Frame->True, 
   FrameLabel->{{"y(t)",None}, 
 {"t","step response for different \[Xi] values"}}, 
   PlotRange->{{0,20},{0,1.6}}, 
   GridLines->Automatic, 
   GridLinesStyle->Dashed, 
   PlotLegend->zValues, 
   LegendPosition->{0.76,-0.5},LegendSize -> 1, 
   LegendLabel -> "\[Xi] values", 
   ImageSize -> 450, 
   LabelStyle -> 14,AspectRatio -> 1 
]
 

pict

Matlab

clear; close all; 
wn = 1; 
z  = .2:.2:1.2; 
t  = 0:0.05:20; 
y  = zeros(length(t),length(z)); 
legendStr = cell(length(z),1); 
 
for i = 1:length(z) 
    [num,den] = ord2(wn,z(i)); 
    num = num*wn^2; 
    [y(:,i),~,~] = step(num,den,t); 
    legendStr(i) = {sprintf('%1.1f',z(i))}; 
end 
plot(t,y); 
legend(legendStr); 
 
title(sprintf( 
 '2nd order system step response with changing %s', 
 '\zeta')); 
 
xlabel('time (sec)'); 
ylabel('amplitude'); 
grid on; 
set(gcf,'Position',[10,10,400,400]);
 

pict

Maple

restart; 
alias(DS=DynamicSystems): 
H   := (w,zeta)->w^2/(s^2+2*zeta*w*s+w^2): 
sys := (w,zeta)->DS:-TransferFunction(H(w,zeta)): 
zetaValues := [seq(i,i=0.1..1.2,.2)]: 
sol:=map(z->DS:-Simulate(sys(1,z), 
                 Heaviside(t)),zetaValues): 
c :=ColorTools:-GetPalette("Niagara"): 
 
plots:-display(seq(plots[odeplot] 
       (sol[i],t=0..20,color=c[i], 
 
 legend=typeset(zeta,"=",zetaValues[i]), 
 legendstyle=[location=right]), 
         i=1..nops(zetaValues)), 
         gridlines=true, 
 title="step response for different damping ratios", 
 labels=[typeset(t),typeset(y(t))]);
 

Instead of using Simulate as above, another option is to use ResponsePlot which gives same plot as above.

restart; 
alias(DS=DynamicSystems): 
c:=ColorTools:-GetPalette("Niagara"): 
H:=(w,zeta)->w^2/(s^2+2*zeta*w*s+w^2): 
sys:= (w,zeta)-> 
    DS:-TransferFunction(H(w,zeta)): 
zetaValues := [seq(i,i=0.1..1.2,.2)]: 
 
sol:=map(i->DS:-ResponsePlot(sys(1,zetaValues[i]), 
 Heaviside(t), 
 duration=14, 
 color=c[i], 
 legend=typeset(zeta,"=",zetaValues[i]), 
 legendstyle=[location=right] 
 ), 
  [seq(i,i=1..nops(zetaValues))] 
   ): 
 
plots:-display(sol,gridlines=true, 
 title="step response for different damping ratios", 
 labels=[typeset(t),typeset(y(t))] 
  );
 

pict