Help regarding use of BVP4C in solving an third order ODE.
Mostra commenti meno recenti
I'm trying to solve a third order ode using BVP4C and I'm getting this error. Any help ?
Attempted to access y(3); index out of bounds because numel(y)=2.
Error in rhs_bvp (line 2) rhs=[y(2); y(3); y(2)-y(1)*y(3)-1];
Error in bvparguments (line 105) testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 129) [n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in Hiemenz (line 4) sol=bvp4c(@rhs_bvp,@bc_bvp,init);
Below is my code
function bc=bc_bvp(yl,yr) %ya(1), ya(2), yb(2)
bc=[yl(1); yl(2); yr(2)-1];
end
function rhs=rhs_bvp(x,y)
rhs=[y(2); y(3); y(2)-y(1)*y(3)-1];
end
init=bvpinit(linspace(0,4,8),[0 0])
sol=bvp4c(@rhs_bvp,@bc_bvp,init);
x=linspace(0,4,8);
BS=deval(sol,x);
plot(BS(:,1),x);
1 Commento
MOSLI KARIM
il 17 Dic 2022
function ANSWER
function bc=bc_bvp(yl,yr) %ya(1), ya(2), yb(2)
bc=[yl(1); yl(2); yr(2)-1;yr(1)];
end
function rhs=rhs_bvp(x,y)
rhs=[y(2); y(3);y(4); y(1)*y(4)-y(2)*y(3)];
end
init=bvpinit(linspace(0,4,8),[0 0 0 0])
sol=bvp4c(@rhs_bvp,@bc_bvp,init);
plot(sol.x,sol.y)
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!