Plotting Signals in matlab

I am still new to matlab and I am facing many errors sketching these problems help please.
2- X(t)=(t+1)u(t-1)-tu(t)-u(t-2) …… for -1≤t≤3
3- X(t)=e-t u(t) – e t-4 u(t-4) …… for -1≤t≤6
4- X[n]=u[n] -2u[n-1] + u[n-4] …… for -3≤n≤8
5- X[n]=δ[n+1]-δ[n]+u[n+1]-u[n-2] ……. for -3≤n≤4

 Accepted Answer

One option is to use the Symbolic Math Toolbox and go from there.
Example —
syms t
u(t) = heaviside(t);
X(t)=(t+1)*u(t-1)-t*u(t)-u(t-2)
X(t) = 
figure
fplot(X, [-1 3])
grid
ylim(1.5*ylim)
That only required copying and pasting the function and adding some necessary multiplication operators before plotting it.
.

3 Comments

well that worked fine for continous signals and I appreciate it but I still need help for discrete ones (4,5) thanks in advance
T = -3:8;
Y = X(T)
stem(T, Y)
@Ahmed Mohamed — As always, my pleasure!
@Walter Roberson — Thank you!
.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!