フィルターのクリア

I need help, How to solve bvp4c error?

2 ビュー (過去 30 日間)
Nadjah
Nadjah 2015 年 1 月 7 日
コメント済み: Nadjah 2015 年 1 月 15 日
Hello, I want to solve the following bvp using bvp4c:
  • The differential equation is: y''''(x)-A(x)y''(x)+B(x)y(x)=f(x)with the boundary conditions: y(0)=y'(0)=0 and y(200)=y'(200)=0
  • The coefficients are:
  • f(x)=diff(psi,4,'x')*(-2*alpha*exp(-alpha*x)) +diff(psi,3,'x')*(6*alpha^2*exp(-alpha*x))++diff(psi,2,'x')*exp(-alpha*x)*(2*1i*alpha^2*diff(psi,'x')-4*alpha^3)-4*alpha^3*exp(-alpha*x)
  • A(x)=(2*alpha^2+1i*alpha*diff(psi,'x')) and B(x)=(alpha^4+1i*(alpha^3*diff(psi,'x') +alpha*diff(psi,3,'x'))).
  • were the parameter psi is a known function of x and alpha is a unknown constant parameter.
  • I rewrite the differential equation as a system of first order equations of the form dydx=F(x,y).
  • I use the following code:
  • function dydx=stream(x,y,psi,alpha) % stream = EDO/BVP the streamfunction corresponding to a turbulent gaz flow % dydx = stream(x,y psi,alpha) evaluates derivative.
  • dydx=[y(2) y(3) y(4) diff(psi,4,'x')*(-2*alpha*exp(-alpha*x)) +diff(psi,3,'x')*(6*alpha^2*exp(-alpha*x))+diff(psi,2,'x')*exp(-alpha*x)*(2*1i*alpha^2*diff(psi,'x')-4*alpha^3)-4*alpha^3*exp(-alpha*x)+(2*alpha^2+1i*alpha*diff(psi,'x'))*y(3)-(alpha^4+1i*(alpha^3*diff(psi,'x')+alpha*diff(psi,3,'x')))*y(1)];
  • end
  • function res = streambc(ya,yb,~)% streambc ODE/BVP streamfuction boundary conditions.% res = streambc(ya,yb) evaluates residual.
  • res=[ya(1);ya(2);yb(1);yb(2)];
  • end
  • function yinit = streaminit % streaminit ODE/BVP streamfuction initial guess.% yinit= streaminit(x) evaluates initial guess at x.
  • yinit=[0;1;0;-1];
  • solinit=bvpinit(linspace(0,200,101),@streaminit);
  • sol= bvp4c(@courant,@streambc,solinit);
  • x=linspace(0.0,200,101);
  • y = deval ( sol, x );
  • plot ( x, y(1,:) );
  • end
  • by running this code, a message appears: "Not enough input arguments"I don't know what I could add as input arguments! Could you please help me understand and solve the problem? I will be very grateful.

回答 (1 件)

Torsten
Torsten 2015 年 1 月 7 日
1. You pass a handle called "courant" to bvp4c, but you supply the derivatives in a function called "stream".
2. If you want to pass psi and alpha to stream, the call to bvp4c must read sol=bvp4c(@(x,y)stream(x,y,psi,alpha),@streambc,solinit);
Best wishes
Torsten.
  3 件のコメント
Torsten
Torsten 2015 年 1 月 8 日
Of course the lines
solinit=bvpinit(linspace(0,200,101),@streaminit);
sol= bvp4c(@courant,@streambc,solinit);
x=linspace(0.0,200,101);
y = deval ( sol, x );
plot ( x, y(1,:) );
have to be outside the function streaminit.
Did you take this into account ?
Best wishes
Torsten.
Nadjah
Nadjah 2015 年 1 月 15 日
  Thank you for your comments. I modified my code and I rested my question because I get other errors.

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

カテゴリ

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