how to inverse signal in matlab ?
23 views (last 30 days)
Show older comments
hello in my exmaple i have this 2 signals : x=[3 11 7 0 -1 4 2] n1=-3:1:3 h=[ 2 3 0 -5 2 1] n2=-1:1:4
and i need to plot this plots : x(k)&h(k),x(k)&h(-k),x(k)&h(-1-k),x(k)&h(2-k) hoe ever so far i did only the first one :
x=[3 11 7 0 -1 4 2]
n1=-3:1:3
h=[ 2 3 0 -5 2 1]
n2=-1:1:4
subplot(2,2,1)
stem(n1,x)
hold on
stem(n2,h,':')
title('x(k) & h(k)');
xlim([-5 5])
xlabel('k')
legend('solid-x','dashed-h');
subplot(2,2,2)
stem(n1,x)
hold on
stem(n2,flip(h),':')
title('x(k) & h(-k)');
xlim([-5 5])
xlabel('k')
legend('solid-x','dashed-h');
how ever the my second plot is wrong . how to inverse my h(k) ? and moving it by 2 ? should run a for loop that will move my signal ?
0 Comments
Answers (1)
Ankita Bansal
on 26 Jun 2018
Hi, for h(-k) you need to change the sign of n2 and you need to flip it also.
Change " stem(n2,flip(h),':') " to:
% for h(-k)
stem(flip(-n2),flip(h),':')
% for h(-1-k)
stem(-1+flip(-n2),flip(h),':')
% for h(2-k)
stem(2+flip(-n2),flip(h),':')
See Also
Categories
Find more on 2-D and 3-D Plots 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!