Plot the function combining an exponential function and a step function
Show older comments
I have a funtion involving exponential functions and one exponent is a step function of x.
The plot I need is y vs x,
y=(e^(2t)-1)*e^(-2.5x) ,
and t is a step function of x
where t=x for x<10
t=10 for x>=10
Please help me to plot such a function in xy space.
syms x ;
t =piecewise(x<10,x,x>=10,10);
y=(exp(2*t)-1)*exp(-2.5*x);
fplot(y)
The curve I got from the code above is clearly not correct. Could anyone tell me what is wrong and how to fix it? Thanks!
Accepted Answer
More Answers (1)
Sam Chak
on 10 Apr 2022
Hi @Nick
Please check the piecewise function
if it is what you desire. Then, check the equation
and the plot.
subplot(2, 1, 1)
fplot(@(x) min(x,10), [-1 15])
grid on
xlabel('x')
ylabel('t')
title('Function t(x)')
subplot(2, 1, 2)
fplot(@(x) (exp(2*min(x, 10))-1).*exp(-2.5*x), [-1 15])
grid on
xlabel('x')
ylabel('y')
title('Function y(x)')
Result

Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!