If we have differential variable of matrix kind ( with dimention 3*3 ) and non matrix ( with dimention 1) simaltanously and as a couple ,how can we use ode45 ?(adsbygoogle = window.adsbygoogle || []).push({});

If we have only matrix kind , we can use m file of ode at first with the command of reshape (3,3) and then change it to column one.What is the solution in this case ?

P,Q,Q :matrices 3*3

Pdot= A*P +P*A’ +Q

K=P*[1 0 0]

xdot(1) =f(x(1),x(2),x(3)) +k(1)*x(1)

xdot(2)=g(x(1),x(2),x(3)) +k(2)*x(2)

xdot(3)=h(x(1) ,x(2),x(3)) +k(3)*x(3)

x0=[ xa;xb;xc]

P0=x01

Example (only matrix differential equation) :

%-----MAIN M-FILE--------------

clear all

%-----VARIABLE SET-UP--------------

A = [0 1 0; 0 0 5; 1 2 3];

Q = [1 0 0; 0 0.5 0; 0 0 0.9];

%-----TO RUN and PLOT ODE SOLUTION--------------

t01= 0;

tf1=30;

tspan1 = LINSPACE(t01, tf1);

X01=zeros(3);

[Time1,X1] = ode45(@(t,X) odefuncare(t,X,A,Q),tspan1,X01);

plot(Time1,X1)

%-------ODEFUNCTION------------------

function dxdt = odefuncare(t,X,A,Q)

X = reshape(X,3,3); %converting X from a column vector generated by ode45 into a 5 x 5 Matrix

dxdt=A*x +x*A’ +Q

dxdt = dxdt(:); %converting dxdt into a column vector as expected by ode45

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB Ode 45 (matlab)

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads for matlab | Date |
---|---|

MATLAB MATLAB: forces acting on an object | Apr 6, 2018 |

MATLAB Matlab histogram | Apr 4, 2018 |

MATLAB Sovling Bernoulli's differential equation in matlab? | Apr 3, 2018 |

MATLAB Matlab-like software | Mar 27, 2018 |

MATLAB Matlab data into bins | Mar 27, 2018 |

**Physics Forums - The Fusion of Science and Community**