Error using DynamicSystem/lsim
8 次查看(过去 30 天)
显示 更早的评论
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]
0 个评论
采纳的回答
Star Strider
2017-11-29
‘My U and T are both same as 1x501 sym and 1x501 double.’
They should both be double. Neither should be sym.
4 个评论
youma
2023-5-11
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
2023-5-11
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!