Problem with the legend command

1 回表示 (過去 30 日間)
Deck Zhan Sim
Deck Zhan Sim 2022 年 1 月 6 日
コメント済み: Deck Zhan Sim 2022 年 1 月 6 日
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:

採用された回答

KSSV
KSSV 2022 年 1 月 6 日
%% 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 件のコメント
Deck Zhan Sim
Deck Zhan Sim 2022 年 1 月 6 日
I managed to solve it already. Thanks for helping!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNeuroimaging についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by