How to plot x(t) = exp(-t)*u(t) using syms symbolic function?
Show older comments
I was asked to plot the function x(t) = exp(-t)*u(t) using symbolic matlab. However, I have been having trouble in creating the unit step function using the 'syms' function. I just wonder how can we set the bound for the value of t?
Attempt 1: trying to set the bound of syms t
syms t positive
syms u
%assume (t>0)
%u = inline('(t>=0)', 't')
x = sym('exp(t)*u')
x
x = subs(x,u,1)
ezplot(x);shg
I have tried to plot the exp(-t) and unit step(t) separately successfully; however, when I multiply them together, it gives me a graph will all zero value.
Attempt 2: trying to add 2 syms function together to create x(t)
syms t u
assume(t < 0)
hold on;
unit = heaviside(t)
subplot(3,1,1);
ezplot(unit)
e = exp(t)
subplot(3,1,2)
ezplot(e)
subplot(3,1,3)
x = sym('exp(t)*u')
ezplot(x);shg
Can someone please help me to point out how I should approach to this problem? I got stuck with this issue for hours and I still haven't been able to figure this out. Thanks!
Answers (1)
Mischa Kim
on 12 Jan 2014
Edited: Mischa Kim
on 12 Jan 2014
Use the heaviside -function:
syms x
ezplot(heaviside(x)*exp(-x), [-2, 2])
Categories
Find more on Symbolic Math Toolbox 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!