Error using lsim, problems setting 'U' matrix.
Show older comments
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)

Answers (1)
Star Strider
on 23 Nov 2020
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 Comments
Elizabeth Heider
on 23 Nov 2020
Star Strider
on 23 Nov 2020
My pleasure!
No worries, and no apology necessary. I know that feeling well!
If my Answer helped you solve your problem, please Accept it!
.
Categories
Find more on Time Series Events in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!