Error using lsim, problems setting 'U' matrix.

I am trying to simulate a State Space system with initial condition w(0) and want to plot x vs y, x vs t, and y vs t. I've looked through numerous forums and examples and this is what I felt made sense to setup the simulation, although I am running into the error following the code. If someone could explain how to set 'U' as a matrix to correlate with T, I think that would be the solution. I apologize if the answer to this already exists.
A = [0 0 1 0;
0 0 0 1;
7.3809 0 0 2;
0 -2.1904 -2 0]
B = [0 0;
1 0;
0 0;
0 1]
C = [1 0 0 0;
0 1 0 0]
sys = ss(A,B,C,0);
y0 = -0.00911
w_xy = 1.86265
kp = 2.91261
w0 = [0;
y0;
((1/kp)*y0*w_xy);
0]
T = 0:0.01:10;
u = zeros(length(t),2)
[x,y] = lsim(sys,u,T,w0)

回答(1 个)

I am not certain what the problem is, other than there is a typographical error in the ‘u’ assignment with ‘t’ inastead of ‘T’:
u = zeros(length(T),2);
With that change, the code works.

2 个评论

Wow, I apologize, insanely sleep deprived, that worked. Thank you so much.
My pleasure!
No worries, and no apology necessary. I know that feeling well!
If my Answer helped you solve your problem, please Accept it!
.

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Time Series Events 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by