필터 지우기
필터 지우기

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