please help i keep getting erro

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 Commenti

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 il 10 Mar 2023
@Samson comment moved here.
That's my second order equations
Torsten
Torsten il 10 Mar 2023
Modificato: Torsten il 10 Mar 2023
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).

Accedi per commentare.

 Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Richiesto:

il 8 Mar 2023

Commentato:

il 13 Mar 2023

Community Treasure Hunt

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

Start Hunting!

Translated by