フィルターのクリア

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.
  1 件のコメント
Dakota Burrow
Dakota Burrow 2013 年 7 月 7 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by