Given the following simple closed loop system, show the step response. Let mass
Using propertional controller
Mathematica
m = 1; c = 1; k = 20; kp = 400; plant = TransferFunctionModel[1/(m s^2 + c s + k), s]; controller = TransferFunctionModel[kp, s]; sys = SystemsModelSeriesConnect[plant, controller]; sys = SystemsModelFeedbackConnect[sys]; o = OutputResponse[sys, UnitStep[t], t]; Plot[o, {t, 0, 10}, Frame -> True, PlotRange -> All, FrameLabel -> {{"y(t)", None}, {"t (sec)", "response of closed loop"}}, BaseStyle -> 14]
Matlab
close all; m = 1; c = 1; k = 20; s = tf('s'); plant = 1/(m*s^2+c*s+k); controller = 400; sys = series(controller,plant); sys = feedback(sys,1); [Y,T] = step(sys,0:.01:10); plot(T,Y); xlabel('time (sec)'); ylabel('y(t)'); title('response of closed loop');
Another way to do the above is
m=1; c=1; k=20; s=tf('s'); sys3=1/(m*s^2+c*s+k); sys2=400; sys1=1; sys=append(sys1,sys2,sys3); Q=[2 1 -3;3 2 0]; input=[1]; output=[2 3]; sys=append(sys1,sys2,sys3); sys=connect(sys,Q,input,output); T=0:.01:10; [Y,T,X]=step(sys,T);