exponential decay function y = exp*(-Tau.time)
90 次查看(过去 30 天)
显示 更早的评论
Another exponential decay function I am having problem with: Need to write script to plot the following equation
y = exp ^ -(timeconstant*time)
prompt the user for beginning and ending values of time vector.
prompt the user for two values of timeconstant
Now, calculate two different y vectors
Here is what I did:
timeconst1 = input('Please enter the first value of time constant: ');
timeconst2 = input('please enter the second value of time constant: ');
initial = input('Please enter the beginning value of time: ');
final = input('Please enter the ending value of time: ');
vec = initial:final;
yinitial = exp(-timeconst1*vec)
plot(initial,yinitial,'r*')
hold on
yfinal = exp(-timeconst2*vec)
plot(final,yfinal,'c*')
0 个评论
采纳的回答
Mischa Kim
2015-1-30
Hi Nabin, to help with readability I have slightly re-formatted the code and re-named some variables:
tau1 = 1;
tau2 = 2;
ti = 1;
tf = 10;
t = linspace(ti,tf,20);
yinitial = exp(-tau1*t);
yfinal = exp(-tau2*t);
plot(t,yinitial,'r*')
hold on
plot(t,yfinal,'c*')
hold off
0 个评论
更多回答(1 个)
ZUBAIR WAR
2022-8-13
tau1 = 1;
tau2 = 2;
ti = 1;
tf = 10;
t = linspace(ti,tf,20);
yinitial = exp(-tau1*t);
yfinal = exp(-tau2*t);
plot(t,yinitial,'r*')
hold on
plot(t,yfinal,'c*')
hold off
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biological and Health Sciences 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!