필터 지우기
필터 지우기

plot summation of shifted discrete signals

조회 수: 2 (최근 30일)
ayman daraghmah
ayman daraghmah 2015년 9월 16일
댓글: Nguyen Hong Son 2020년 4월 17일
n=-4:2;
y=[1,-2,4,6,-5,8,10];
n=n-2
stem(n,y);
I want to plot Z = y(n-2)+y(n+1);

채택된 답변

Hamoon
Hamoon 2015년 9월 17일
편집: Hamoon 2015년 9월 17일
n=-4:2;
y=[1,-2,4,6,-5,8,10];
maxShift = 10; % maximum shift that you may want,
% you can't shift more than this value,
% you should set this value high enough
% I could set it to be 2 here, but I prefer 10
n=min(n)-maxShift:1:max(n)+maxShift; % define proper range for n
y=[zeros(1,maxShift), y, zeros(1,maxShift)]; % add zeros to the begining and
% end of y
z= circshift(y',-2) + circshift(y',1); % calculate your new signal. you need
% transpose of y ==> y'
  댓글 수: 2
Hamoon
Hamoon 2015년 9월 17일
here is the output using:
subplot(2,1,1)
stem(n,y);
title('y')
axis([-15 15 -10 20])
subplot(2,1,2)
stem(n,z);
title('z')
axis([-15 15 -10 20])
Nguyen Hong Son
Nguyen Hong Son 2020년 4월 17일
Excuse me. Can I ask you why we can use circular shift to compute operations of shifted discrete signals? (I can't have the intuition or visualization of it)
Why do we need the transpose of y in the last line of code?
Thank you so much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by