how this will be plotted

Status
Not open for further replies.

moonnightingale

Full Member level 6
Joined
Sep 17, 2009
Messages
362
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Activity points
3,832
this is condition after inverse Z transform
I want to plot it

y[n]= u[n-1]-u[n-2]-u[n-3]+u[n-4]
 

I guess u[n] is the step function, right?
Try yourself:
u[n-1] is u[n] delayed 1 sample, ...etc...
Plot the 4 parts and add graphically.
Regards

Z
 

this is condition after inverse Z transform
I want to plot it

y[n]= u[n-1]-u[n-2]-u[n-3]+u[n-4]



Code:
function y=ustep(x)
Y=zeros(size(x));
Y(x>=0)=1;
y=Y


eg
Code:
t=-10:1:10;
plot(t,t.*ustep(t)-(t-2).*ustep(t-2)-(t-3).*ustep(t-3)+(t-5).*ustep(t-5))
grid on 
xlabel('t')
ylabel('x(t)')



Discrete


Code:
n=-10:1:10;
stem(n,n.*ustep(n)-(n-2).*ustep(n-2)-(n-3).*ustep(n-3)+(n-5).*ustep(n-5))
grid on 
xlabel('n')
ylabel('x(n)')


 

@ Blooz:

Why do you multply each shifted step by the functions (t-...) or (n-...)?
That gives ramps.
Regards

Z
 

@ Blooz:

Why do you multply each shifted step by the functions (t-...) or (n-...)?
That gives ramps.
Regards

Z

hi Zorro
just an example . .

Blooz

---------- Post added at 19:28 ---------- Previous post was at 19:17 ----------

And here is the solution for

y[n]= u[n-1]-u[n-2]-u[n-3]+u[n-4]




Code:
n=-10:1:10;
stem(n,ustep(n-1)-ustep(n-2)-ustep(n-3)+ustep(n-4))
grid on 
xlabel('n')
ylabel('x(n)')

 

One thing to remark:
The sequence is 0, 1, 0 -1, 0, 0, 0,...
In the plot above, n=0 is at the middle.
Regards

Z
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…