MATLAB Answers

Is there any missing in my simulation via lsim?

1 view (last 30 days)
I have a state space model below and my inputs are u1=[0.1 0.1] and u2=[1000 1000] for t=[0 0.01]. I have created a simulation via lsim, but cannot interpret the result. y contains 2 row and 5 colums.
First and second row of y matrix may be response of u1 and u2, respectively. Is it true? If not, what kind of changes should be implemented?
Thanks a lot!
clear all
tspan=[0 0.01]
[y,tspan]=lsim(sys,[0.1*ones(1,numel(tspan)); 1000*ones(1,numel(tspan))],tspan);

Accepted Answer

Deepak Gupta
Deepak Gupta on 3 Dec 2020
Edited: Deepak Gupta on 3 Dec 2020
Hi Volkan,
I am not being sarcastice, just a suggetion, i think you should go through the basics of state space modeling. for better understanding.
Looking at the matrices in the code, i drive following.
Sizes of matrices... A = 3*3, B = 3*2; C = 5*3, and D = 5*2;
Now state space equtions are
diff(x) = Ax+Bu
y = Cx+Du;
So from second equation you can see dimentions of C and D decide the number of outputs you are generating. Mutiplication of C with x with give you 5*3*3*1 = 5*1 and so will multiplication of D and u i.e. Du = 5*2*2*1 = 5*1.
So the output you are getting is correct.
Note: From your comments i get impresstion that you think, outputs will be the size of input vector but that's not true. One input can generate multiple outputs, it simply depends upon the design of your system.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by