フィルターのクリア

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.
  1 件のコメント
Torsten
Torsten 2018 年 10 月 5 日
What is h' ?

サインインしてコメントする。

採用された回答

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 Center および File ExchangeBoundary Value Problems についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by