How to obtain State space model response ?

조회 수: 103 (최근 30일)
Anand
Anand 2011년 2월 2일
댓글: Rik 2021년 12월 29일
Hello friends i need one help on matab M-file programming. I have a Transfer function, it is easy to converter into state-space(A,B,C,D). For step and impulse signals inbuilt commands are available(like step(u*ss), impulse(u*ss)). But suppose my input is time varying other than step and impulse, how to obtain the output response. I am confused which ccommand is to use to get output response !
Assume TF = 1/(s+2) , i/p signal =square or sine or any time varing input. How to write M-file for this case?

답변 (3개)

Paulo Silva
Paulo Silva 2011년 2월 2일
[A,B,C,D]=tf2ss([1],[1 2]) %[1] or 1 is the same thing in this case
t = 0:0.01:2; %do the simulation from 0 to 2 seconds with step 0.01
%3 possible inputs, you can test with other inputs
%just be sure that u is the same size has t
%u = [1 zeros(1,numel(t)-1)]; %impulse
u = ones(1,numel(t)); %step
%u = t; %ramp
x0 = 0; %initial condition of system states
[y,x] = lsim(A,B,C,D,u,t,x0); %do the simulation
plot(t,y,t,u)
legend('Response','Input')
  댓글 수: 1
Rik
Rik 2021년 12월 29일
Comment posted as flag by @Hamid Reza Ashrafi:
great example for explaining the algorithm to extract a response of space state model to a specific input

댓글을 달려면 로그인하십시오.


Rajiv Singh
Rajiv Singh 2012년 9월 17일
see LSIM

Jamie
Jamie 2012년 8월 28일
In the ofchance that others are also having a little bit or trouble plotting the system response a couple of simple examples are provided in the matlab documentation in the appended link (both forced and unforced MIMO and SISO)

Community Treasure Hunt

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

Start Hunting!

Translated by