Azzera filtri
Azzera filtri

I want to plot Isocline i.e want plot (x,y) when system contains step function .

7 visualizzazioni (ultimi 30 giorni)
% Parameters
r =0.1; % Define the value of r
k = 50; % Define the value of k
a =0.01; % Define the value of a
e = 0.5; % Define the value of e
m = 0.05; % Define the value of m
F = 1; % Define the value of F
%s =0.1; % Define the value of s
w = 0.1; % Define the value of w
b = 0.001; % Define the value of b
M = 50; % Define the value of M
s =0.1; % Define the value of sx
% Initial conditions
x0 =2; % Define the initial value of x
y0 =1; % Define the initial value of y
initial_conditions = [x0; y0];
% Time span for simulation
tspan = [0, 100]; % Define the time span (e.g., [0, 10])
% Solve the system of differential equations
[t, y] = ode45(@(t, y) kkk(t, y, r, k, a, e, m, F, s, w, b, M, x), tspan, initial_conditions);
Unrecognized function or variable 'x'.

Error in solution>@(t,y)kkk(t,y,r,k,a,e,m,F,s,w,b,M,x) (line 20)
[t, y] = ode45(@(t, y) kkk(t, y, r, k, a, e, m, F, s, w, b, M, x), tspan, initial_conditions);

Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
% Extract the solution
x_sol = y(:, 1);
y_sol = y(:, 2);
function dydt = kkk(t,x,y, r, k, a, e, m, F, s, w, b, M)
x = y(1);
u = isocline_input(x, F, s, w, b, M);
dxdt = r * x * (1 - x / k) - a * x * y / (1 + q * u * M);
dydt = (e * a * x * y) / (1 + q * u * M) - m * y;
dydt = [dxdt; dydt];
end
function u = isocline_input(x, F,w, b, M, s)
pi0 = (w * F) / (s * (w + b * M));
pi1 = F * (w + b * M) / (s * w);
if x <= pi0
u = 0;
elseif x >= pi1
u = 1;
else
u = (s*x) / (s*x + F) + w * (s*x - F) / (b * (s*x + F) * M);
end
end
I want to plot (x,y) where is my fault please help
  7 Commenti
mks
mks il 1 Ago 2023
Modificato: Walter Roberson il 1 Ago 2023
% Parameters
r =0.1; % Define the value of r
k = 50; % Define the value of k
a =0.01; % Define the value of a
e = 0.5; % Define the value of e
m = 0.05; % Define the value of m
F = 1; % Define the value of F
%s =0.1; % Define the value of s
w = 0.1; % Define the value of w
b = 0.001; % Define the value of b
M = 50; % Define the value of M
s =0.1; % Define the value of sx
% Initial conditions
x0 =2; % Define the initial value of x
y0 =1; % Define the initial value of y
initial_conditions = [x0; y0];
% Time span for simulation
tspan = [0, 100]; % Define the time span (e.g., [0, 10])
% Solve the system of differential equations
[t, y] = ode45(@(t, state) kkk(t,state,r, k, a, e, m, F, s, w, b, M), tspan, initial_conditions);
x = state(1); y = state(2);
% [t, y] = ode45(@(t, state) kkk(t, state, r, k, a, e, m, F, s, w, b, M),
% Extract the solution
x_sol = y(:, 1);
y_sol = y(:, 2);
function dydt = kkk(t,x,y, r, k, a, e, m, F, s, w, b, M)
x = y(1);
u = isocline_input(x, F, s, w, b, M);
dxdt = r * x * (1 - x / k) - a * x * y / (1 + q * u * M);
dydt = (e * a * x * y) / (1 + q * u * M) - m * y;
dydt = [dxdt; dydt];
end
function u = isocline_input(x, F,w, b, M, s)
pi0 = (w * F) / (s * (w + b * M));
pi1 = F * (w + b * M) / (s * w);
if x <= pi0
u = 0;
elseif x >= pi1
u = 1;
else
u = (s*x) / (s*x + F) + w * (s*x - F) / (b * (s*x + F) * M);
end
end
sir, please see and help . I have tired

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 1 Ago 2023
Spostato: Walter Roberson il 1 Ago 2023
Your code needs q but you did not define any q, so I had to pick SOME value for q in order to debug.
You need to change the definition of q to something appropriate for your situation.
% Parameters
r =0.1; % Define the value of r
k = 50; % Define the value of k
a =0.01; % Define the value of a
e = 0.5; % Define the value of e
m = 0.05; % Define the value of m
F = 1; % Define the value of F
%s =0.1; % Define the value of s
w = 0.1; % Define the value of w
b = 0.001; % Define the value of b
M = 50; % Define the value of M
s =0.1; % Define the value of sx
%user's code does not define any q, but we need a value of it to debug
rng(655321)
q = rand() * 10 %define the value of q
q = 3.1402
% Initial conditions
x0 =2; % Define the initial value of x
y0 =1; % Define the initial value of y
initial_conditions = [x0; y0];
% Time span for simulation
tspan = [0, 100]; % Define the time span (e.g., [0, 10])
% Solve the system of differential equations
[t, y] = ode45(@(t, state) kkk(t, state, r, k, a, e, m, F, s, w, b, M, q), tspan, initial_conditions);
% Extract the solution
x_sol = y(:, 1);
y_sol = y(:, 2);
subplot(2,1,1); plot(t, x_sol); title('x');
subplot(2,1,2); plot(t, y_sol); title('y');
function dydt = kkk(t, state, r, k, a, e, m, F, s, w, b, M, q)
x = state(1);
y = state(2);
u = isocline_input(x, F, s, w, b, M);
dxdt = r * x * (1 - x / k) - a * x * y / (1 + q * u * M);
dydt = (e * a * x * y) / (1 + q * u * M) - m * y;
dydt = [dxdt; dydt];
end
function u = isocline_input(x, F, s, w, b, M)
pi0 = (w * F) / (s * (w + b * M));
pi1 = F * (w + b * M) / (s * w);
if x <= pi0
u = 0;
elseif x >= pi1
u = 1;
else
u = (s*x) / (s*x + F) + w * (s*x - F) / (b * (s*x + F) * M);
end
end
  2 Commenti
mks
mks il 1 Ago 2023
why are you maintion 'u' as isclinefun
Here u is an adaptive step function .Which is contained in our system. My paper says that
1.when q=0.02,F=1
x=0:50;y=0:20,The system has an equilibrium point.
2.when q=0.03,F=1.714
x=0:50;y=0:20,The system has three equilibrium points
3.when q=0.02,F=1.8
x=0:50;y=0:20,The system has an equilibrium point.
4.when q=0.02,F=1.37
x=0:50;y=0:20,The system has an equilibrium point
5.
when q=0.03,F=1.613
x=0:50;y=0:20,The system have two equilibrium points
Give me suggetions how i can draw this plot(x,y)
I actually find the equilibrium points for choice of q and alternative resource F
Sam Chak
Sam Chak il 1 Ago 2023
What exactly do you mean by "u is an Adaptive Step Function"? I tried searching the keywords, but they seem unrelated. A closer look shows that depends on the parameter that is defined through 3 static (non-dynamic) If-Else statements, making it looks like the scheduling approach.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by