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!