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 Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

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