function sol=samsonwork
global Br Sc delta P K R n epsilon
%x=linspace(-1,1,11);
r=0:0.01:3;
Br=1;Sc=0.4;n=3;delta=0;R=0.5;epsilon=0.1;P=0.3;K=0.3;
solinit=bvpinit(r,[0,0,0,0,0,0]);
sol=bvp4c(@samsonfun,@samsonbc,solinit);
% plot(ans.x(1,:),ans.y(1,:))
end
function f=samsonfun(~,y)
% -Df*y(8)
global Br Sc delta P K R n epsilon g
g = y(3)/ (1+epsilon*y(3));
f=[y(2)
-P
y(4)
R*y(4)-Br*(y(2))^2+delta*(1+epsilon*y(3))* exp g
y(6)
Sc*K*(1+epsilon*y(3))^n *exp g];
end
function res=samsonbc(ya,yb)
%global s lambda alpha
res=[ya(1)
yb(1)-1
ya(3)
yb(3)
ya(5)-1
yb(5)];
end

3 件のコメント

Torsten
Torsten 2023 年 3 月 8 日
What is
R*y(4)-Br*(y(2))^2+delta*(1+epsilon*y(3))* exp g
Sc*K*(1+epsilon*y(3))^n *exp g];
?
Torsten
Torsten 2023 年 3 月 10 日
@Samson comment moved here.
That's my second order equations
Torsten
Torsten 2023 年 3 月 10 日
編集済み: Torsten 2023 年 3 月 10 日
What I mean is:
"exp g" is not a valid MATLAB expression - it will throw an error.
So which mathematical object should "exp g " represent ?
Do you mean exp(g) ? In this case, your code works (see below).

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

 採用された回答

Torsten
Torsten 2023 年 3 月 10 日

1 投票

samsonwork()
ans = struct with fields:
solver: 'bvp4c' x: [0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900 0.3000 0.3100 0.3200 0.3300 … ] y: [6×301 double] yp: [6×301 double] stats: [1×1 struct]
function sol=samsonwork
global Br Sc delta P K R n epsilon
%x=linspace(-1,1,11);
r=0:0.01:3;
Br=1;Sc=0.4;n=3;delta=0;R=0.5;epsilon=0.1;P=0.3;K=0.3;
solinit=bvpinit(r,[0,0,0,0,0,0]);
sol=bvp4c(@samsonfun,@samsonbc,solinit);
plot(sol.x,[sol.y(1,:);sol.y(2,:)])
% plot(ans.x(1,:),ans.y(1,:))
end
function f=samsonfun(~,y)
% -Df*y(8)
global Br Sc delta P K R n epsilon g
g = y(3)/ (1+epsilon*y(3));
f=[y(2)
-P
y(4)
R*y(4)-Br*(y(2))^2+delta*(1+epsilon*y(3))* exp(g)
y(6)
Sc*K*(1+epsilon*y(3))^n *exp(g)];
end
function res=samsonbc(ya,yb)
%global s lambda alpha
res=[ya(1)
yb(1)-1
ya(3)
yb(3)
ya(5)-1
yb(5)];
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

質問済み:

2023 年 3 月 8 日

コメント済み:

2023 年 3 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by