Problem with the legend command

2 Ansichten (letzte 30 Tage)
Deck Zhan Sim
Deck Zhan Sim am 6 Jan. 2022
Kommentiert: Deck Zhan Sim am 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:

Akzeptierte Antwort

KSSV
KSSV am 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 Kommentar
Deck Zhan Sim
Deck Zhan Sim am 6 Jan. 2022
I managed to solve it already. Thanks for helping!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Neuroimaging finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by