Problem with the legend command

2 vues (au cours des 30 derniers jours)
Deck Zhan Sim
Deck Zhan Sim le 6 Jan 2022
Commenté : Deck Zhan Sim le 6 Jan 2022
Hi, I have an issue with the legend command. When the legend command is coded, it should be showing the graph line respectively. But now my problem is the legend command it gives me the same line graph color. May I know how to solve it? I will be grateful that someone can solve this matter. Thanks!
Here is the source code:
%% Initialize Input
K = 1000000000; % Carrying Capacity of Brain Tumor
C0 = 40000; % Initial Brain Tumor Population Size
r = 4.31*(10^-3); % Growth Rate of Brain Tumor Cells
kt = 0.9; % Fractional tumor cells killed by drugs of chemotherapy
D = 0.001; % Chemo Doses
%% Model Data
t = 1:7300; % Time in Days
% Calculating Brain Tumor Population
C = (C0*K)./(C0+((K-C0)*exp(-r*t)));
C1 = (C0*K)./(C0+((K-C0)*exp(-(r-kt*D)*t)));
%% Graph Plotting
figure (1)
plot(t,K,'--co','LineWidth',0.5,'MarkerSize',5,'MarkerEdgeColor','cyan')
hold on
plot(t,C,'--bo','LineWidth',0.5,'MarkerSize',5,'MarkerEdgeColor','black')
hold on
plot(t,C1,'--ro','LineWidth',0.5,'MarkerSize',5,'MarkerEdgeColor','red')
hold on
title( 'Brain Tumor Population Against Time' )
xlabel('Time (Days)')
ylabel('Brain Tumor Population (cells)')
legend('k','Without Chemotherapy','With Chemotherapy')
grid
Here is the output:

Réponse acceptée

KSSV
KSSV le 6 Jan 2022
%% Initialize Input
K = 1000000000; % Carrying Capacity of Brain Tumor
C0 = 40000; % Initial Brain Tumor Population Size
r = 4.31*(10^-3); % Growth Rate of Brain Tumor Cells
kt = 0.9; % Fractional tumor cells killed by drugs of chemotherapy
D = 0.001; % Chemo Doses
%% Model Data
t = 1:7300; % Time in Days
% Calculating Brain Tumor Population
C = (C0*K)./(C0+((K-C0)*exp(-r*t)));
C1 = (C0*K)./(C0+((K-C0)*exp(-(r-kt*D)*t)));
%% Graph Plotting
K = K*ones(size(t)) ;
figure (1)
plot(t,K,'c','LineWidth',0.5)
hold on
plot(t,C,'b','LineWidth',0.5)
plot(t,C1,'r','LineWidth',0.5)
title( 'Brain Tumor Population Against Time' )
xlabel('Time (Days)')
ylabel('Brain Tumor Population (cells)')
legend({'k','Without Chemotherapy','With Chemotherapy'})
grid
  1 commentaire
Deck Zhan Sim
Deck Zhan Sim le 6 Jan 2022
I managed to solve it already. Thanks for helping!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Neuroimaging dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by