help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: step response of a state space system


From: Ozzy Lash
Subject: Re: step response of a state space system
Date: Tue, 9 Jan 2018 10:42:34 -0600



On Tue, Jan 9, 2018 at 5:27 AM, Beginner1 <address@hidden> wrote:
Hi!
I am a very beginner in Octave. I need your help in the following task:
I need to obtain and plot the step response of a system whose state-space
matrices are known and it can be represented by

xdot=A*x+B*u
y=C*x+D*u

For this purpose, I have written this code:

/%State-space system parameters
w=314.159;
ki=1.5;
kp=5000;
A=[0 1 0 0 0 0; 0 0 1 0 0 0; 0 -4*w^2 0 0 0 0;0 0 0 0 1 0;0 0 0 0 0 1;0 0 0
0 -4*w^2 0];
B=[0 0 0 0 0 0; 0 0 0 0 0 0;0 0 -1 0 1 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 -1 0
1];
C=[2*(w^2)*ki  0  ki  0  ki*w  0;0 ki*w 0 2*(w^2)*ki 0 ki];
D=[1 0 -kp 0 kp 0;0 1 0 -kp 0 kp];

%Perform system simulation

stname = {'xd1', 'xd2', 'xd3','xq1','xq2','xq3'};
sys = ss (A, B,C,D,'stname', stname)
t=linspace(0,3,1000)
[y,t,x]=step(sys)
plot(t,y)
/

However, an error message is obtained at the console for the command
plot(t,y) saying that the dimensions of one of the plot arrays are not
correct.

Any suggestion?


You have a 6 input, 2 output system, so y is a 3 dimensional array, with the first dimension being the same as the length of t, the second dimension 2 and the third dimension 6.  So if you want to plot one of the outputs, it would be:

plot(t,y(:,1,1)

Note that step will plot all of the step responses if you call it with no output arguments. So if you had just done

step(sys);

you would have seen all of the responses. 

Another note, you are creating t with linspace, but not passing it to step, so step will decide on its own time scale.  If you want to use your own time scale, pass it to step:

step(sys,t);

Bill

reply via email to

[Prev in Thread] Current Thread [Next in Thread]