MATLAB Answers

How Can I add input disturbance for a given specific time gap on a second order transfer function

11 views (last 30 days)
Ismail Sahin YESILGOZ
Ismail Sahin YESILGOZ on 30 Aug 2020
Answered: Paul on 31 Aug 2020
I am trying to draw a graph of a servo controller. There is a 0.1N step unit input exist at the beginning of the model, after a minute, step disturbance input will be applied as 10N reversely for a minute and then removed at the end of this time.
I just wrote this code on the below to get step response for the first minute but I couldnt figure it out what to do about the disturbance input and also how to show it on the same graph
s=tf('s');
wn=6;
z=2/3;
Gs=wn^2/(s^2+2*z*wn*s+wn^2)
figure,step(Gs,60);
Can you please help me about it?
Thanks in advance.

  0 Comments

Sign in to comment.

Answers (1)

Paul
Paul on 31 Aug 2020
Do either of these options do what you're looking for?
s=tf('s');
wn=6;
z=2/3;
Gs=wn^2/(s^2+2*z*wn*s+wn^2);
% define a time vector, make sure that t=60 is exactly in the vector
t = (0:12000)/100;
% Assume the question means that the the input u = 0.1 for t<60 and u = -10 t>=60 seconds. Code below can be
% easily changed if the quetions really meant u = 0.1 for t t <60 and u = (0.1 - 10) for t>=60.
% Option 1: use the scaling and superposition properties of an LTI system
y = step(Gs,t);
y1 = 0.1*y;
y2 = 0*t(:);
ii = find(t>=60);
y2(ii) = -10.1*y(1:length(ii));
yoption1 = y1 + y2;
% Option 2: use LSIM
u = 0*t;
u(t<60) = 0.1;
u(t>=60) = -10;
yoption2 = lsim(Gs,u,t);
plot(t,[yoption1 yoption2]),grid

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!