Clear Filters
Clear Filters

solving state variable equation in matlab

14 views (last 30 days)
tomer polsky
tomer polsky on 22 Oct 2017
Answered: Star Strider on 25 Oct 2017
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 ?

Answers (4)

M
M on 22 Oct 2017
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 on 22 Oct 2017
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 on 24 Oct 2017

Star Strider
Star Strider on 25 Oct 2017
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.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!