필터 지우기
필터 지우기

How to properly plot data points

조회 수: 1 (최근 30일)
Dakota Burrow
Dakota Burrow 2013년 7월 7일
Hi, I need to know the proper way I should plot my data such that I do not have to plot within the for loop, and so that the points will connect with a line.
clc
clear
SO = 8;
vm = 0.7;
ks = 2.5;
F =@(sm,t) SO-vm*t+ks*log(SO/sm)-sm;
sl = 0;
su = 9;
n = 6;
es = 0.5*10^(2-n);
for t = linspace(0,40,50)
sm = michaelis_menten(sl,su,es,t,F);
hold on;
plot(t,sm,'-');
hold off;
end
xlabel('Time(day)');
ylabel('Subtrate Concentration (moles/L)');
title('Substrate Concentration vs Time');
the function michaelis_menten is
function sm = michaelis_menten(sl,su,es,t,F)
ea = 1;
so = 1*10^8;
while ea > es
sm = (sl+su)/2;
if F(sl,t)*F(sm,t)< 0
su =sm;
elseif F(sl,t)*F(sm,t)>0
sl = sm;
else
so = sm;
end
ea = 100*abs((sm - so)/sm);
so = sm;
end
end

채택된 답변

the cyclist
the cyclist 2013년 7월 7일
Here's one way:
numberTimes = 50;
t = linspace(0,40,numberTimes);
figure
for nt = 1:numberTimes
sm(nt) = michaelis_menten(sl,su,es,t(nt),F);
end
plot(t,sm,'-');
xlabel('Time(day)');
ylabel('Subtrate Concentration (moles/L)');
title('Substrate Concentration vs Time');
If your subfunction could be vectorized (which I did not check), you could avoid the for-loop completely.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by