exponential decay function y = exp*(-Tau.time)
조회 수: 69 (최근 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에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!