Error using DynamicSystem/lsim

8 views (last 30 days)
David Ling
David Ling on 29 Nov 2017
Commented: Star Strider on 11 May 2023
0 down vote favorite I am running a dynamic system but I got an error saying:
Error using DynamicSystem/lsim (line 84)
When simulating the response to a specific input signal, the input data U must be a matrix of numeric values with at least two rows
(samples) and without any NaN or Inf.
Error while evaluating UIControl Callback
My code is
[vabls.ResponseYdata vabls.ResponseXdata] = lsim(vabls.ctf,vabls.numinput,vabls.tset);
My U and T are both same as 1x501 sym and 1x501 double. My sys is
814500
------------------------
s^2 + 361.2 s + 8.145e05
where numerator is [0,0,814500] and deniminator is [1,361.2000,8.1450e+05]

Accepted Answer

Star Strider
Star Strider on 29 Nov 2017
‘My U and T are both same as 1x501 sym and 1x501 double.’
They should both be double. Neither should be sym.
  4 Comments
youma
youma on 11 May 2023
Hello @Star Strider I'm having a look alike error with my code.
function [cost, ceq] = drone_costfunction(x, systemea, yref, Q, R, t, u)
Q(1,1) = x(1);
Q(3,3) = x(2);
Q(5,5) = x(3);
R(1,1) = x(4);
R(2,2) = x(5);
K = lqr(systemea.A, systemea.B, Q, R);
sys_cl = ss(systemea.A - systemea.B*K, systemea.B, systemea.C, systemea.D);
y = lsim(sys_cl, u, t); %where the error occurs
ceq = [];
cost = sum((yref-y(:,1)).^2);
end
knowing that u and t, are taken with
[yref,y,u,t] =sys(A,B,C,D)
size(u)
ans =
94 1
size(t)
ans =
94 1
"Error using DynamicSystem/lsim
When simulating the response to a specific input signal, the input data U must be a matrix with as many rows as samples in the time
vector T, and as many columns as input channels.
I can't seem to understand what can possibly be wrong here. Thanks in advance for your help.
Star Strider
Star Strider on 11 May 2023
I can’t determine what the problem is, however the ‘B’ matrix likely has more than one column (input channel).
To get a definitive response, post this as a new Question, and supply the function arguments, preferably as a .mat file. Without those, it can’t be run or simulated.
Stopping here.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!