the reult is different using `ilaplace` and `lsim `

6 views (last 30 days)
i just want to get the output when i know the input signal and trans fer function however when i use 2 methods they are different,codes are as this
method 1
syms t s
gs=(s)/(s^2 + 2*s +1);
us= laplace(sin(t + pi/6), t, s);
xs = us*gs;
xt = ilaplace(xs, s, t)
t=0:0.1:50;
xt2=cos(t)/4 + sin(t)/4 - (3^(1/2)*cos(t))/4 + (3^(1/2)*sin(t))/4 + exp(-t)*(3^(1/2)/4 - 1/4);
plot(t,xt2,'b')
method 2
num=[1,0];
den=[1,2,1]
sys=tf(num, den);
t=0:0.1:50;
u=sin(t+pi/6);
y=lsim(sys, u,t);
plot(t,y,'r')
and when i plot them together the result is as this together.png
  1 Comment
David Goodmanson
David Goodmanson on 23 Dec 2019
Hi d^2,
I'm not sure where xt2 is coming from, but in the first method, plotting xt gives a result that looks very close to the lsim method. I don't have access to lsim so I can't say if the agreement is identical but it looks really close.
xt2 doesn't look right because gs has a double pole and xt2 does not have a t*e^(-t) term, whereas xt does.

Sign in to comment.

Answers (0)

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!