Filter löschen
Filter löschen

exponential decay function y = exp*(-Tau.time)

68 Ansichten (letzte 30 Tage)
Nabin SUNAM
Nabin SUNAM am 30 Jan. 2015
Beantwortet: ZUBAIR WAR am 13 Aug. 2022
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*')

Akzeptierte Antwort

Mischa Kim
Mischa Kim am 30 Jan. 2015
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

Weitere Antworten (1)

ZUBAIR WAR
ZUBAIR WAR am 13 Aug. 2022
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

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by