I want to plot parameters and time , with influence three others paramaters , but i dont know how to plot
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have this matlab code ,
i want to make plotting like this picture
tau vs phi , in my code it is same label , but u from this picture is v from my code . I dont know how to plot tau as function of phi , whre phi is which loss of 10% x[4] in my code, according 0.6 to 0.54, so in interval of phi=[0,250] what time tau get decrease of x[4] from initial value 0.6 to 0.54. with variant of v . thank you
function hdot = glioma0(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr)
% Define the system of ODEs for glioma0
hdot = zeros(7, 1);
v = 0.0;
Phi = 3.3e-3;
H = 0;
if x(6) > 0 || x(7) > 0
H = 1;
end
hdot(1) = Pg * x(1) * (1 - x(1)) - beta1 * x(1) * (x(2) + x(3)) - (d10 + d11 * x(4) + d12 * x(7)) * (x(1) * x(6)) / (a1 + x(1));
hdot(2) = Ps * x(2) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta2 * x(1) * x(2) - u * x(2) * H - v * H * x(2) - (d20 + d21 * x(4) + d22 * x(7)) * x(2) * x(6) / (a2 + x(2));
hdot(3) = Pr * x(3) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta3 * x(1) * x(3) + u * x(2) * H - v * H * x(3);
hdot(4) = mu * (x(2) + x(3)) + pe * x(4) * (1 - x(4)) - d4 * x(4) * x(7) / (a4 + x(4));
if hdot(1) < 0
hdot(5) = alpha * hdot(1) * x(5) - (d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
elseif hdot(1) > 0
hdot(5) = -(d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
end
hdot(6) = Phi - (psi + c1 * x(1) / (a1 + x(1)) + c2 * x(2) / (a2 + x(2)) + c5 * x(5) / (a5 + x(5))) * x(6);
hdot(7) = delta - (gamma + c4 * x(4) / (a4 + x(4))) * x(7);
end
function hdot = glioma01(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr)
% Define the system of ODEs for glioma01
hdot = zeros(7, 1);
v = 0.03;
Phi = 3.3e-3;
H = 0;
if x(6) > 0 || x(7) > 0
H = 1;
end
hdot(1) = Pg * x(1) * (1 - x(1)) - beta1 * x(1) * (x(2) + x(3)) - (d10 + d11 * x(4) + d12 * x(7)) * (x(1) * x(6)) / (a1 + x(1));
hdot(2) = Ps * x(2) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta2 * x(1) * x(2) - u * x(2) * H - v * H * x(2) - (d20 + d21 * x(4) + d22 * x(7)) * x(2) * x(6) / (a2 + x(2));
hdot(3) = Pr * x(3) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta3 * x(1) * x(3) + u * x(2) * H - v * H * x(3);
hdot(4) = mu * (x(2) + x(3)) + pe * x(4) * (1 - x(4)) - d4 * x(4) * x(7) / (a4 + x(4));
if hdot(1) < 0
hdot(5) = alpha * hdot(1) * x(5) - (d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
elseif hdot(1) > 0
hdot(5) = -(d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
end
hdot(6) = Phi - (psi + c1 * x(1) / (a1 + x(1)) + c2 * x(2) / (a2 + x(2)) + c5 * x(5) / (a5 + x(5))) * x(6);
hdot(7) = delta - (gamma + c4 * x(4) / (a4 + x(4))) * x(7);
end
function hdot = glioma1(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr)
% Define the system of ODEs for glioma1
hdot = zeros(7, 1);
v = 0.003;
Phi = 3.3e-3;
H = 0;
if x(6) > 0 || x(7) > 0
H = 1;
end
hdot(1) = Pg * x(1) * (1 - x(1)) - beta1 * x(1) * (x(2) + x(3)) - (d10 + d11 * x(4) + d12 * x(7)) * (x(1) * x(6)) / (a1 + x(1));
hdot(2) = Ps * x(2) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta2 * x(1) * x(2) - u * x(2) * H - v * H * x(2) - (d20 + d21 * x(4) + d22 * x(7)) * x(2) * x(6) / (a2 + x(2));
hdot(3) = Pr * x(3) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta3 * x(1) * x(3) + u * x(2) * H - v * H * x(3);
hdot(4) = mu * (x(2) + x(3)) + pe * x(4) * (1 - x(4)) - d4 * x(4) * x(7) / (a4 + x(4));
if hdot(1) < 0
hdot(5) = alpha * hdot(1) * x(5) - (d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
elseif hdot(1) > 0
hdot(5) = -(d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
end
hdot(6) = Phi - (psi + c1 * x(1) / (a1 + x(1)) + c2 * x(2) / (a2 + x(2)) + c5 * x(5) / (a5 + x(5))) * x(6);
hdot(7) = delta - (gamma + c4 * x(4) / (a4 + x(4))) * x(7);
end
% Initial conditions
x0 = [0.6; 0.6; 0.0; 0.0; 0.6; 0.0; 0.0];
% Time span
t = 0:1:1000;
% Parameters
Pg = 0.0068;
Ps = 0.012;
Pr = 0.002;
pe = 0.002;
beta1 = 1.8e-2;
beta2 = 1.8e-3;
beta3 = 1.8e-3;
d4 = 0.71;
u = 0.01;
a1 = 1;
a2 = 1;
a4 = 1;
a5 = 1;
c1 = 0.0002;
c2 = 0.032;
c4 = 0.032;
c5 = 0.0012;
d10 = 4.7e-8;
d11 = 4.0e-8;
d12 = 3.9e-8;
d20 = 7.8e-2;
d21 = 0.04;
d22 = 7.5;
d50 = 4.7e-3;
d51 = 4.0e-3;
d52 = 3.9e-3;
tau = 0.15;
mu = 0.004;
psi = 0.01813;
delta = 2.4e-4;
gamma = 0.136;
alpha = 2;
% Solve the ODEs for glioma0
[t, y0] = ode45(@(t, x) glioma0(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr), t, x0);
% Solve the ODEs for glioma01
[t, y01] = ode45(@(t, x) glioma01(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr), t, x0);
% Solve the ODEs for glioma1
[t, y1] = ode45(@(t, x) glioma1(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr), t, x0);
% Plot the results
figure;
plot(t, y0(:, 5), 'r', 'LineWidth', 2, 'DisplayName', '\rho=0');
hold on;
plot(t, y1(:, 5), 'b', 'LineWidth', 2, 'DisplayName', '\rho=0.003');
plot(t, y01(:, 5), 'k', 'LineWidth', 2, 'DisplayName', '\rho=0.03');
% Add labels and legend
xlabel('Time (Days)');
ylabel('Concentration of Cell g_4(t)');
legend('Location', 'Best');
title('Glioma Model');
grid on;
hold off;
0 commentaires
Réponses (1)
Les Beckham
le 14 Nov 2023
Modifié(e) : Les Beckham
le 15 Nov 2023
Note that, in Matlab, functions must be defined at the end of a script.
Your code seems to run just fine after reordering it.
Can you please explain what isn't working the way you want it to?
This part of your question is very confusing:
tau vs phi , in my code it is same label , but u from this picture is v from my code . I dont know how to plot tau as function of phi , whre phi is which loss of 10% x[4] in my code, according 0.6 to 0.54, so in interval of phi=[0,250] what time tau get decrease of x[4] from initial value 0.6 to 0.54. with variant of v . thank you
% Initial conditions
x0 = [0.6; 0.6; 0.0; 0.0; 0.6; 0.0; 0.0];
% Time span
t = 0:1:1000;
% Parameters
Pg = 0.0068;
Ps = 0.012;
Pr = 0.002;
pe = 0.002;
beta1 = 1.8e-2;
beta2 = 1.8e-3;
beta3 = 1.8e-3;
d4 = 0.71;
u = 0.01;
a1 = 1;
a2 = 1;
a4 = 1;
a5 = 1;
c1 = 0.0002;
c2 = 0.032;
c4 = 0.032;
c5 = 0.0012;
d10 = 4.7e-8;
d11 = 4.0e-8;
d12 = 3.9e-8;
d20 = 7.8e-2;
d21 = 0.04;
d22 = 7.5;
d50 = 4.7e-3;
d51 = 4.0e-3;
d52 = 3.9e-3;
tau = 0.15;
mu = 0.004;
psi = 0.01813;
delta = 2.4e-4;
gamma = 0.136;
alpha = 2;
% Solve the ODEs for glioma0
[t, y0] = ode45(@(t, x) glioma0(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr), t, x0);
% Solve the ODEs for glioma01
[t, y01] = ode45(@(t, x) glioma01(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr), t, x0);
% Solve the ODEs for glioma1
[t, y1] = ode45(@(t, x) glioma1(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr), t, x0);
% Plot the results
figure;
plot(t, y0(:, 5), 'r', 'LineWidth', 2, 'DisplayName', '\rho=0');
hold on;
plot(t, y1(:, 5), 'b', 'LineWidth', 2, 'DisplayName', '\rho=0.003');
plot(t, y01(:, 5), 'k', 'LineWidth', 2, 'DisplayName', '\rho=0.03');
% Add labels and legend
xlabel('Time (Days)');
ylabel('Concentration of Cell g_4(t)');
legend('Location', 'Best');
title('Glioma Model');
grid on;
hold off;
function hdot = glioma0(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr)
% Define the system of ODEs for glioma0
hdot = zeros(7, 1);
v = 0.0;
Phi = 3.3e-3;
H = 0;
if x(6) > 0 || x(7) > 0
H = 1;
end
hdot(1) = Pg * x(1) * (1 - x(1)) - beta1 * x(1) * (x(2) + x(3)) - (d10 + d11 * x(4) + d12 * x(7)) * (x(1) * x(6)) / (a1 + x(1));
hdot(2) = Ps * x(2) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta2 * x(1) * x(2) - u * x(2) * H - v * H * x(2) - (d20 + d21 * x(4) + d22 * x(7)) * x(2) * x(6) / (a2 + x(2));
hdot(3) = Pr * x(3) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta3 * x(1) * x(3) + u * x(2) * H - v * H * x(3);
hdot(4) = mu * (x(2) + x(3)) + pe * x(4) * (1 - x(4)) - d4 * x(4) * x(7) / (a4 + x(4));
if hdot(1) < 0
hdot(5) = alpha * hdot(1) * x(5) - (d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
elseif hdot(1) > 0
hdot(5) = -(d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
end
hdot(6) = Phi - (psi + c1 * x(1) / (a1 + x(1)) + c2 * x(2) / (a2 + x(2)) + c5 * x(5) / (a5 + x(5))) * x(6);
hdot(7) = delta - (gamma + c4 * x(4) / (a4 + x(4))) * x(7);
end
function hdot = glioma01(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr)
% Define the system of ODEs for glioma01
hdot = zeros(7, 1);
v = 0.03;
Phi = 3.3e-3;
H = 0;
if x(6) > 0 || x(7) > 0
H = 1;
end
hdot(1) = Pg * x(1) * (1 - x(1)) - beta1 * x(1) * (x(2) + x(3)) - (d10 + d11 * x(4) + d12 * x(7)) * (x(1) * x(6)) / (a1 + x(1));
hdot(2) = Ps * x(2) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta2 * x(1) * x(2) - u * x(2) * H - v * H * x(2) - (d20 + d21 * x(4) + d22 * x(7)) * x(2) * x(6) / (a2 + x(2));
hdot(3) = Pr * x(3) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta3 * x(1) * x(3) + u * x(2) * H - v * H * x(3);
hdot(4) = mu * (x(2) + x(3)) + pe * x(4) * (1 - x(4)) - d4 * x(4) * x(7) / (a4 + x(4));
if hdot(1) < 0
hdot(5) = alpha * hdot(1) * x(5) - (d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
elseif hdot(1) > 0
hdot(5) = -(d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
end
hdot(6) = Phi - (psi + c1 * x(1) / (a1 + x(1)) + c2 * x(2) / (a2 + x(2)) + c5 * x(5) / (a5 + x(5))) * x(6);
hdot(7) = delta - (gamma + c4 * x(4) / (a4 + x(4))) * x(7);
end
function hdot = glioma1(t, x, Pg, Ps, pe, beta1, beta2, a1, a2, a4, a5, c1, c2, c4, c5, u, d10, d11, d12, d20, d21, d22, d50, d51, d52, d4, tau, mu, beta3, psi, delta, gamma, alpha, Pr)
% Define the system of ODEs for glioma1
hdot = zeros(7, 1);
v = 0.003;
Phi = 3.3e-3;
H = 0;
if x(6) > 0 || x(7) > 0
H = 1;
end
hdot(1) = Pg * x(1) * (1 - x(1)) - beta1 * x(1) * (x(2) + x(3)) - (d10 + d11 * x(4) + d12 * x(7)) * (x(1) * x(6)) / (a1 + x(1));
hdot(2) = Ps * x(2) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta2 * x(1) * x(2) - u * x(2) * H - v * H * x(2) - (d20 + d21 * x(4) + d22 * x(7)) * x(2) * x(6) / (a2 + x(2));
hdot(3) = Pr * x(3) * (1 - (x(2) + x(3)) / (1 + tau * x(4))) - beta3 * x(1) * x(3) + u * x(2) * H - v * H * x(3);
hdot(4) = mu * (x(2) + x(3)) + pe * x(4) * (1 - x(4)) - d4 * x(4) * x(7) / (a4 + x(4));
if hdot(1) < 0
hdot(5) = alpha * hdot(1) * x(5) - (d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
elseif hdot(1) > 0
hdot(5) = -(d50 + d51 * x(4) + d52 * x(7)) * x(5) * x(6) / (a5 + x(5));
end
hdot(6) = Phi - (psi + c1 * x(1) / (a1 + x(1)) + c2 * x(2) / (a2 + x(2)) + c5 * x(5) / (a5 + x(5))) * x(6);
hdot(7) = delta - (gamma + c4 * x(4) / (a4 + x(4))) * x(7);
end
5 commentaires
Les Beckham
le 15 Nov 2023
That still doesn't make sense. Where is the code that you are using to try to plot your desired plot? What isn't working? Does the code that you posted have anything to do with what you want to do? Which variables in that code are you wanting to plot? Don't make us guess what you are trying to do.
Voir également
Catégories
En savoir plus sur View and Analyze Simulation Results dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!