Error in Bvp4c
3 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
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
その他の回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Boundary Value Problems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!