how to inverse signal in matlab ?

19 次查看(过去 30 天)
tomer polsky
tomer polsky 2018-6-26
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 ?

回答(1 个)

Ankita Bansal
Ankita Bansal 2018-6-26
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),':')

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by