plot summation of shifted discrete signals
1 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
采纳的回答
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
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
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 Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!