Solve state space equation by ODE45
303 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everybody.
I am new to state space representation. please help me to solve this question.
I have state space equation for IM motor like this:
xdot=A.x+B.u --> and their dimensions are : [50,1]=[50,50]*[50,1]+[50,50]*[50,1]
I have calculated A & B and I need to get xdot. (there are no C & D)
1- how should I write my function? (I don't use Simulink)
2- I used my solver like this:
>> [t,y] = ode45(@sys, tspan, zeros(50,1));
Thanks in advance.
0 Commenti
Risposta accettata
Yu Jiang
il 8 Ago 2014
Hi Babak
In order to solve an ODE using ode45, you need to first define the function to describe the complete dynamics. In the linear state space system you provided, the definition of u is missing. In general, u can be designed as a linear feedback control law, such as u = Kx, where K is a 50-by-50 matrix. Let me give you a simpler example here. Suppose we have A = [0 1; -2 3]; B = [0;1]; K = [-1 -1]; Then, the system function can be constructed as
function dx = sys(t, x)
A = [0 1; -2 3]; B = [0;1]; K = [-1 -1];
u = K*x
dx = A*x + B*u;
end
Please save the above function in an MATLAB file and name is as sys.m
Then, in a separate MATLAB script file or in the command window, you can simulate the system by executing the following
>> tspan = [0 10];
>> iniCon = [1;-1]
>> [t, y] = ode45(@sys, tspan, iniCon);
If you would like to show the simulation result in a figure, try executing >> plot(t,y)
5 Commenti
Più risposte (4)
Babak
il 9 Ago 2014
1 Commento
Yu Jiang
il 9 Ago 2014
Modificato: Yu Jiang
il 11 Ago 2014
From what I understand, this is not an issue with MATLAB, but an issue with control theory.
In standard state-space-based control design, the control signal u is usually a function of x, not a function of xdot. If it is the later case, I think you may need to do some math to rearrange the terms with dot operation to the left-hand side of the equation.
Again, bear in mind that ode45 is used for autonomous systems in the form of dx = f(t,x). No derivative terms of x should appear on the right hand side. If you define Tm using xdot and use it as part of the input u, you are actually introducing xdot to the right hand side of the equation.
Delcio Macaia
il 19 Ott 2016
Heloo, i have some questions to ask i have a state space, dx/dt = Ax(t) + Bu(t) , y = C x(t) + D u(t) i know all the values and the size of the matrix's
A is a (6*6)matrix B is a (6*1)matrix C is a (6*6) matrix D is a (6*1) mtrix
i need to input a signal in my state space system, the signal is a vector (6000*2),
in the first column i have the time and the second column i have the acelerations
Ts is my simple time Ts = 0.02 the interval of the integration is 0 to 120 [0 120]
so if i put in matlab --> sys = ss(A,B,C,D,Ts )
how can i input my signal and how can a solve it whit the ODE45 ?
THANKS
0 Commenti
Yasir Ghazi
il 15 Nov 2017
I have Linearized model state-space show below [I need to plot output (P&Q) in matlab ]
where
a=[-100 -628.32 -1000 0 0 0 0 0 0 0 0;226.19 -100 0 -1000 0 0 0 0 0 0 0;100000 0 0 -628.32 -104790 0 102500 0 0 0 0;0 1e6 226.19 0 0 -37726 0 36902 0 0 0;0 0 325.55 0 -45.54 -376.99 44.375 50.528 212.38 0 0;0 0 0 325.55 376.99 -45.54 -50.528 44.375 -14.612 0 0;0 0 0 0 28.905 0 -29.551 1.5489 1591.1 0 0;0 0 0 0 0 28.905 -1.5489 -29.551 -109.47 0 0;0 0 0 0 0.87472 -0.060182 -0.89748 0.014545 -1.0531 16849 42.123;0 0 0 0 0 0 0 0 -0.025 0 1;0 0 0 0 0 0 0 0 1.25 -20000 -55.302];
b=[4331.6 5243.1 0 0 0;0 -6371.2 -97980 0 0;22411 -4527.5 -7979600 0 0;-7619.9 -17920000 3041500 0 0;-222.94 0 0 0 0;24.59 0 0 0 0;-1591.1 0 0 0 0;109.47 0 0 0 0;0.39844 0 0 0 0;0 0 0 0 0;0 0 0 22.848 -5.3188];
c=[9798 0 0 0 0 0 0 0 0 0 0;0 -16330 0 0 0 0 0 0 0 0 0];
d=[219.62 0 -24528 0 0;108.44 136279 137990 0 0];
and Input, state and output variables at the operating point for linearization
1 Commento
ANIL KUMAR BALLA
il 30 Mar 2019
i need to give speed bump and steering as inputs to my state space block, but my inputs are in graphical form how to give these two inputs to the same state space block.
Yower Jymmy
il 26 Apr 2021
Yu Jiang Can you tell me how I plot input signal u from (dx/dt) = A*x + B*u with ode45?
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!