Lsim function returns an array filled with Nan
7 views (last 30 days)
Show older comments
Im using lsim to simulate a MVE, for some reason the response y2 is filled with NaN when It should have the system response.
R=1;
C1=1*10^-6;
L=1*10^-3;
A= [1/C1 -1/C1 0; -2*(R/L) R/L -1/L; R/L (-5/2)*(1/L) 1/L];
B= [0 0; 1/L 0; 0 -1/(2*L)];
C= [0 1/2 0; 0 0 1];
D= [0 1/(2*R); 0 0];
sys = ss(A,B,C,D);
t2 = 0:0.01:20;
u1 = 5*heaviside(t2-3);
u2 = 10*heaviside(t2-6);
u = [u1(:), u2(:)];
[y2,t2]=lsim(sys,u,t2);
y2
0 Comments
Answers (1)
Paul
on 12 Jan 2023
Hi Gabriel,
Recheck the model. As written it has two unstable poles way out in the right half plane. That will be very difficult to simulate.
R=1;
C1=1*10^-6;
L=1*10^-3;
A= [1/C1 -1/C1 0; -2*(R/L) R/L -1/L; R/L (-5/2)*(1/L) 1/L];
B= [0 0; 1/L 0; 0 -1/(2*L)];
C= [0 1/2 0; 0 0 1];
D= [0 1/(2*R); 0 0];
sys = ss(A,B,C,D);
format short e
eig(sys)
heaviside(0)
You can change that 1 using sympref, which is probably what you want. Or define a new function like
unitstep = @(t) 0.5*(t==0) + heaviside(t);
unitstep(0)
0 Comments
See Also
Categories
Find more on Robust Control Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!