0
\$\begingroup\$

I have a system defined in state space model with the following matrices

A =

$$ \begin{matrix} 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ -1280 & -254 & -26 & 3400 \\ -1 & 0 & 0 & 0 \\ \end{matrix} $$

B =

$$ \begin{matrix} 0 \\ 0 \\ 1 \\ 0 \\ \end{matrix} $$

C = $$ \begin{matrix} 1 & 0 & 0 & 0 \\ \end{matrix} $$

D= 0

As you see I have 4 state variables , I want to plot them against time with step input in matlab.

\$\endgroup\$
  • \$\begingroup\$ The simplest way would be to run a simulation. \$\endgroup\$ – Eugene Sh. May 24 '17 at 19:11
  • \$\begingroup\$ @EugeneSh. Sorry but can you elaborate more ? \$\endgroup\$ – Shady Atef May 24 '17 at 19:12
  • 1
    \$\begingroup\$ You have the initial state. You have the state-space equation. These two are giving you the momentary change in the state (it's time derivative at time 0). You multiply it by time step and add to the current state to obtain the next one. The smaller time steps, the more accurate it is. \$\endgroup\$ – Eugene Sh. May 24 '17 at 19:15
1
\$\begingroup\$

Looks like matlab step function can already do that

I have solved it using the following equations:

[y,t,x] = step(ss_model,1) % X here will have trajectories for the 
x1 = [ 1 0 0 0]*x';
x2 = [ 0 1 0 0]*x';
x3 = [ 0 0 1 0]*x';
x4 = [ 0 0 0 1]*x';
\$\endgroup\$
1
\$\begingroup\$

There is a better way:

close all; clear all; clc;

A = [0 1 0 0; 0 0 1 0; -1280 -254 -26 3400; -1 0 0 0];
B = [0;0;1;0];
C = [1 0 0 0];
D = [0];

sys = ss(A,B,C,D);
[y,t,x] = step(sys);
plot(t,x);
legend('x1','x2','x3','x4');
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.