using shooting method for coupled ode
Ältere Kommentare anzeigen
Hi all,
please help,I'm looking to solve the following system of equations with boundary conditions using the shooting method:
The equation and m-file attached .
I've found the solution using the BVP4C solver but need to also be able to find the solution using the shooting method.
I'm really quite new to MATLAB and don't really know where to start!
Any help anyone can give me would be greatly appreciated. Thanks!
1 Kommentar
darova
am 13 Apr. 2020
Can you rewrite this part?
function f= projfun(x,y)
f= [y(2)
y(1)*y(3)+x*y(2)*y(3)+y(1)*y(2)+(y(9)*(1/alfa*Pr*x))-(y(2)/x)-(y(1)/(x*x))
(-1/x)*(4*y(3)+y(2)+(y(1)/x))
4*y(3)*y(3)+((x*y(3)+y(1)-(1/x))*((-1/x)*(4*y(3)+y(2)+(y(1)/x))))
y(6)
Pr*x*y(3)*y(6)+Pr*y(1)*y(6)-(y(6)/x)
y(8)
(1/B*Tinf)*(alfa*Pr*y(1)*y(8)+alfa*Pr*x*y(3)*y(8)-(((DT*Bs*Fiinf)/(Tinf*Dfi))*((Pr*x*y(3)*y(6)+Pr*y(1)*y(6)-(y(6)/x))-(y(6)/x))))
y(9)
];
end
To make it look like:
function f= projfun(x,y)
E
E = y(1);
dE = y(2);
F = y(3);
dF = y(4);
% ...
f = zeros(9,1);
f(1) = dF;
f(2) = long_expr1;
f(3) = long_expr2;
% ...
end
- Use variable instead of y(1),y(2) for long code
- Why not define f function as you did before?
example
[1 - 2; 2] % work
[1 -2; 2] % doesn't work
I can't check your function because it's difficult to read. I don't want to write new one
Antworten (1)
Thank you more readable code
Here are some mistakes



Some note:

Shouldn't last equations be like this? What is g? There is no g in your equations
% g = y(7);
E = y(7);
dE = y(8);
% dy(7) = dg;
dy(7) = -1*(4*E+df+f); % E'
dy(8) = (4*E*E)+((E*x+f-1)*(-1*(4*E+df+f))); % E''
You can just use nested functions
function proj
% global variables - no need
% code
function dy = projfun(x,y)
% global variables - no need
% code
end
end
14 Kommentare
darova
am 14 Apr. 2020
But what is g? Looks like it's constant. If it exists the previous version was correct also
T K
am 14 Apr. 2020
T K
am 14 Apr. 2020
darova
am 14 Apr. 2020
It's ok i think. I tried ode45 to see how results can look like
[x,y] = ode45(@projfun,[0 1],y0);
plot(x,y)
str = strsplit(sprintf('y%d ',1:9),' ');
legend(str)

I did my best. Don't know how proceed
T K
am 14 Apr. 2020
darova
am 14 Apr. 2020
I tried to reduce timespan
m = linspace(0,1);

T K
am 14 Apr. 2020
darova
am 14 Apr. 2020

darova
am 14 Apr. 2020

T K
am 14 Apr. 2020
darova
am 14 Apr. 2020
Don't forget about thumb up
darova
am 18 Apr. 2020
How can i trust you?
T K
am 18 Apr. 2020
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!