how to inverse signal in matlab ?

조회 수: 13 (최근 30일)
tomer polsky
tomer polsky 2018년 6월 26일
댓글: 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),':')
  댓글 수: 1
tomer polsky
tomer polsky 2018년 6월 26일
ohh i forgot to flip the n2 ... thank you very much my friend .

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by