필터 지우기
필터 지우기

Error in Bvp4c

조회 수: 1 (최근 30일)
Priya M
Priya M 2021년 10월 23일
답변: MOSLI KARIM 2023년 11월 27일
I'm trying to run the following bvp4c MATLAB code, but keep running into an error:
please anyone find out my mistakes and correct me..
Thank you.

채택된 답변

Jan
Jan 2021년 10월 23일
You define the variable beta on top of the code, but this does not mean, that it is known in all subfunctions. Pr, gamma and lam are not known inside also.
Either define the constants, where they are needed, or provide them using an anonymous function:
for gamma=0.0:0.25:1
sol = bvpinit(linspace(0,5,50),[0 0 0 0 0 0 0]);
fcn = @(t,y) bvpexam1(t, y, beta, gamma, lam, Pr);
sol1 = bvp4c(fcn, @bcexam1,sol);
...
end
function ysol = bvpexam1(t, y, beta, gamma, lam, Pr)
...
end
  댓글 수: 5
Jan
Jan 2021년 10월 27일
편집: Jan 2021년 10월 27일
f =@(x,y)[y(2);
...
(1/(1+E*y(6)-Pr*gamma*y(1)^2))*(-E*y(7)^2-Pr*y(1)*y(7)+Pr*gamma*y(1)*y(2)*y(7))];
% ^
There is a missing closing square bracket in your code. After adding it I get a result.
Priya M
Priya M 2021년 10월 28일
Thanx a lot sir....

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

추가 답변 (1개)

MOSLI KARIM
MOSLI KARIM 2023년 11월 27일
this code works function d
Pr=0.72;
beta=0.5;
lam=0.2;
E=0.5;
for gamma=0.0:0.25:1
sol = bvpinit(linspace(0,5,50),[0 0 0 0 0 0 0]);
sol1 = bvp4c(@bvpexam1, @bcexam1,sol);
x1 = sol1.x;
y1 = sol1.y;
figure (1)
plot(x1, y1(2,:));
hold on
figure (2)
plot(x1, y1(6,:));
hold on
z = y1(3,1);
p = y1(7,1)'
figure(3)
plot(gamma,y1(7,1),'-bo')
hold on
end
function res = bcexam1(y0, yinf)
res=[y0(1)-0;y0(2)-1;y0(4)-0;y0(6)-1;yinf(2)-0;yinf(4)-0;yinf(6)-0];
end
function ysol = bvpexam1(~,y)
yy1 = (1/(1-beta*y(1)^2))*(-y(1)*y(3)+y(2)^2-2*lam*(y(4)-beta*y(1)*y(5))-2*beta*y(1)*y(2)*y(3));
yy2 = (1/(1-beta*y(1)^2))*(-y(1)*y(5)+y(2)*y(4)+2*lam*(y(2)+beta*(y(2)^2-y(1)*y(3)+y(4)))-2*beta*y(1)*y(2)*y(5));
yy3 = (1/(1+E*y(6)-Pr*gamma*y(1)^2))*(-E*y(7)^2-Pr*y(1)*y(7)+Pr*gamma*y(1)*y(2)*y(7));
ysol = [y(2);y(3);yy1;y(5);yy2;y(7);yy3];
end

카테고리

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