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 CenterFile Exchange에서 Neuroimaging에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by