Lsim function returns an array filled with Nan

6 Ansichten (letzte 30 Tage)
Gabriel
Gabriel am 12 Jan. 2023
Beantwortet: Paul am 12 Jan. 2023
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
y2 = 2001×2
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

Antworten (1)

Paul
Paul am 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)
ans = 3×1
1.0e+00 * 1.0020e+06 1.5801e+03 -1.5791e+03
Also, be careful using heaviside. If using the default sympref, then we have
heaviside(0)
ans =
5.0000e-01
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)
ans =
1

Kategorien

Mehr zu Robust Control Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by