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 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