ode45 for the shooting method.

I want to predict a constant for the target height for the given ode problem. The target height is highly dependent on the constant alpha. Some one told me to use shooting /iterative methods but I am new for such a method. I need your help.
zspan=[0,400];
v0mat = [1 0.01 1];
zsol = {};
v1sol = {};
v2sol = {};
v3sol = {};
for k=1:size(v0mat,1)
v0=v0mat(k,:);
[z,v]=ode45(@rhs,zspan,v0);
zsol{k}=z;
v1sol{k}=v(:,1);
v2sol{k}=v(:,2);
v3sol{k}=v(:,3);
end
for r=1:length(v2sol)
q(r)=r;
end
for k1 = 1:length(v2sol)
zsol04(k1) = interp1(v2sol{k1}, zsol{k1}, 0.4);
end
figure()
scatter(q,zsol04,'p')
xlabel('q')
ylabel('Height')
function parameters=rhs(z,v)
alpha=0.08116;
db= 2*alpha-(v(1).*v(3))./(2*v(2).^2);
dw= (v(3)./v(2))-(2*alpha*v(2)./v(1));
dgmark= -(2*alpha*v(3)./v(1));
parameters=[db;dw;dgmark];
end

7 comentarios

Torsten
Torsten el 6 de Abr. de 2018
The problem is not clear from your description.
Dereje  Beyene
Dereje Beyene el 6 de Abr. de 2018
The above code gives height at a point where v2sol is 0.4. Now this result is highly dependent on alpha which I used constant value. Now I want to go the other way. Let’s I don’t have alpha, but I have height. My question is for what value of alpha will I get the given height. I am not sure if I explained it well.
Torsten
Torsten el 6 de Abr. de 2018
Editada: Walter Roberson el 7 de Abr. de 2018
Use "bvp4c" with three boundary conditions at h=0, one boundary condition as v2(height)=0.4 and a free parameter alpha.
The example
"Compute Fourth Eigenvalue of Mathieu’s Equation"
under
will show you how to proceed.
Here, lambda plays the role of your alpha.
Best wishes
Torsten.
Dereje
Dereje el 7 de Abr. de 2018
Thanks!! It is a good starting point.
Dereje
Dereje el 7 de Abr. de 2018
But with only one boundary conditions there is an error : 'The boundary condition function BCFUN should return a column vector of length 4'
function res= mat4bc(ya,yb,alpha)
% ya=0.01;yb=0.4;
res=[yb(1) alpha];
res=res(:);
end
Torsten
Torsten el 9 de Abr. de 2018
Please read my answer again:
Use "bvp4c" with three boundary conditions at h=0, one boundary condition as v2(height)=0.4 and a free parameter alpha.
Best wishes
Torsten.
Dereje
Dereje el 9 de Abr. de 2018
Hi Torsten, Yes I get it now. I was mixing the two boundary conditions. Thanks a lot!! It was better if u put your comments in the 'Answer this question' section so that I could be able to accept the answer.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Abr. de 2018

Comentada:

el 9 de Abr. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by