MATLAB Solving coupled ODEs with Matlab

  • Thread starter mika
  • Start date
I was wondering how coupled ODEs could be solved with Matlab.. I'm having trouble passing the coupling solution vectors between solvers since the length of the vectors isn't constant during the iteration e.g.

sol1 = bvpinit(linspace(0.,h,200),[0.1 0]);
sol2 = bvpinit(linspace(0.,h,200),@mat4init);


sol1 = bvp4c(@fODE,@fBC,sol1,options1,g,Re,K);
sol2 = bvp4c(@gODE,@gBC,sol2,options1,f,Re,K);

function dydx = fODE(x,y,g,Re,K)

dydx = [ y(2,:)

function dgdx = gODE(x,y,g,Re,K)

dgdx = [ g(2,:)

this doesn't work bacause the dimensions of y and g dont match during iteration. Any ideas how to overcome this?

Want to reply to this thread?

"Solving coupled ODEs with Matlab" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving