Vin
Vin

Reputation: 1

Integrate differential equations in Matlab

I am facing a problem in which I have to solve a system of equations:

\partial A \delta x = f(A) g(B)

\partial B \delta y = h(A) k(B)

in which f,g,h and k are some functions of A or B, and I have some initial conditions A(x=0) = a, B (y=0) = b. All previous variables are scalars.

I have solved this by making a little step in one variable and then integrating the other other equation for the whole range of the other variable (like an ode routine), then another step in the former variable and so on.

Do you have another idea more efficient? Is it possible to put one ode call running inside another call? Or perhaps there is something more elegant like combining both independent variables x and y, integrating a vector function and then undoing the change? I have the feeling that this could be done in some way.

Many thanks!

Upvotes: 0

Views: 167

Answers (1)

laureapresa
laureapresa

Reputation: 179

This looks to me like a partial differential equation system. You can solve it with pdepe (here is the documentation) or you can discretize one dimension, let's say x, in Np points and have one y-equation on each point. You would complicate your system from 2 equations to Np, but turn it from PDE to ODE and therefore solvable with Matlab's ODEs.

Upvotes: 0

Related Questions