System of ODE
Show older comments
Hi, I'm very new with Matlab. I have been trying to solve a system of ODE with 100 or even more equations. I know how to solve one ODE or system of ODE (with few equations) with ODE45. Writting more than 100 equations in the function file is very tedious. So I'm thinkg to write the function file in matrix form. For example:
dydt = A * y
Where dydt = [dy1/dt
dy2/dt
......
......
dyn/dt];
A = [a1 a2 a3 ..... ...............an
b1 b2 b3.......bn
.................
.................
n1 n2 n3 ......nn]
y = [y1
y2
..
yn];
(n >= 100)
I have already generated my A matrix. I just would like to know how can I write the code for implement "dydt = A * y" in the function file.
I really appreacite for any kind of assistance.
Thanks.
Answers (1)
Matt Tearle
on 5 Mar 2011
You already have the code: dy = A*y. Given how simple it is, you don't even need to write a function file -- you could just use an anonymous function handle:
odefun = @(t,y) A*y;
[t,y] = ode45(odefun,t0,y0);
But if your ODE is linear, why do you even need to use ode45? A linear system has an analytic solution. You could possibly use eig and/or expm to work out whatever you need.
Categories
Find more on Ordinary Differential Equations 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!