solving state variable equation in matlab

14 次查看(过去 30 天)
hello i am trying this eqution :
dx/dt=A*x+B*u
y=C*x
while A is matrix 4X4,B is matrix 4X1,C is matrix 1X4,and u is constant , how do i find X ? if X should be matrix of 4X1 , and how do i draw graph of x ?

回答(4 个)

M
M 2017-10-22
WHat do you want to do exactly ?
If you want to simulate your system with a given input, you can use specific function, such as step, impulse etc...
You can also solve your ODE system with the matlab ode45 solver.

tomer polsky
tomer polsky 2017-10-22
ye i tried to use ode system but i cant understand how to write it.could you write me example for second order code ?

M
M 2017-10-24

Star Strider
Star Strider 2017-10-25
Your integrated differential equation is the matrix exponential, given by the expm function (in both base MATLAB and the Symbolic Math Toolbox).
The integration of your system is:
dx/dt = A*x + B*u % Time-Domain Differential Equation
y = C*x
sX = A*X + B*U % Laplace Transformed System
Y = C*X
sX - A*X = B*U % Rearrange
Y = C*X
(s*I -A)*X = B*U % Combine Terms, ‘I’ Is The Identity (‘eye’) Matrix
Y = C*X
X = inv(s*I - A)*B*U % Solve For ‘X’ (Do Not Use ‘inv’), Illustration Only Here
Y = C*X
Y = C*(inv(s*I - A)*B*U) % Substitute
y(t) = C*expm(A*t)*B*u(t) % Inverse Laplace Transform To Get Solved Differential Equation
This is straightforward to calculate in a loop.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by