필터 지우기
필터 지우기

MATLAB solving BVP using bvp4c

조회 수: 8 (최근 30일)
Taylor Nichols
Taylor Nichols 2018년 10월 4일
댓글: Torsten 2018년 10월 5일
I am trying to solve a BVP in matlab using the bvp4c function. The following equation is a 3rd order linear homogeneous ODE with constant coefficients. I have solved second order linear and non-linear but I can't seem to figure out how to do a third order. I cannot find and documentation on how to make this adjustment.
The equation: y''' = a*h'
with boundary conditions y(0) = 0.3; y(15) = 0.7; y'(0) = 0;
The main code I have tried is below:
init = bvpinit(linspace(1,15,10),[0,0]);
sol = bvp4c(@rhs_bvp, @bc_bvp, init);
x = linspace(1,15,100);
BS = deval(sol, x);
plot(x,BS(1,:));
using the bc_bvp funtion below:
function [ bc ] = bc_bvp( yl, yr )
hi = 0.3;
ho = 0.7;
bc = [yl(1) - hi;
yl(2);
yr(1) - ho];
end
and the rhs_bvp function below:
function [ rhs ] = rhs_bvp( x, y )
a = 26;
rhs = [y(3); a*y(2)];
end
and I get this error:
Index exceeds matrix dimensions.
Error in rhs_bvp (line 8)
rhs = [y(3); a*y(2)];
Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Any help would be greatly appreciated.

채택된 답변

Torsten
Torsten 2018년 10월 5일
If h' = y', try
function main
init = bvpinit(linspace(1,15,10),[0,0,0]);
sol = bvp4c(@rhs_bvp, @bc_bvp, init);
x = linspace(1,15,100);
BS = deval(sol, x);
plot(x,BS(1,:));
end
function [ rhs ] = rhs_bvp( x, y )
a = 26;
rhs = [y(2); y(3); a*y(2)];
end
function [ bc ] = bc_bvp( yl, yr )
hi = 0.3;
ho = 0.7;
bc = [yl(1) - hi;
yl(2);
yr(1) - ho];
end
Best wishes
Torsten.
  댓글 수: 2
Taylor Nichols
Taylor Nichols 2018년 10월 5일
Thanks for the help Torsten! I guess including a picture of how I broke down the function would've helped. So if we have a 3rd order function we need to have 3 initial guesses? I'm also confused on why we set up the rhs variable that way too. I have only seen examples on 2nd order. And no detailed documentation on using this method exist. If you have anymore quick pointers it would be greatly appreciated!
Torsten
Torsten 2018년 10월 5일
https://en.wikipedia.org/wiki/Ordinary_differential_equation
Section "Reduction of order"

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Boundary Value Problems에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by