How to plot this discrete signal?

조회 수: 24 (최근 30일)
Jay
Jay 2021년 3월 20일
답변: Kiran Felix Robert 2021년 3월 23일
Given:
x(n) = {2, 4, -3, 1, -5, 4,7 }
n = [-4, -3, -2, -1, 0, 1, 2]
Plot the following using the stem function:
I am following Proaksis DSP using Matlab and I have the following thus far.
[x11, n11] = sigshift(xn, n, 1);
[x12, n12] = sigshift(xn, n, 2);
[x13, n13] = sigshift(xn, n, 3);
[x14, n14] = sigshift(xn, n, 4);
[x15, n15] = sigshift(xn, n, 5);
function [y,n] = sigshift(x, m, n0)
n = m + n0;
y = x;
end
Where I am just simply shifting the signal. I am having problems on scaling the signal by n which is a vector instead of a scalar.

채택된 답변

Kiran Felix Robert
Kiran Felix Robert 2021년 3월 23일
Hi Jay,
I assume that the following is the equation you are trying to implement and plot,
The following code demonstrates this,
n = -4:2;
x = [2,4,-3,1,-5,4,7];
% padding zeros
X = [0,0,0,0,0,x];
y = zeros(1,length(n));
for i = 1:length(y)
y(i) = i*(X(i) + X(i+1) + X(i+2) + X(i+3) + X(i+4));
end
stem(n,y)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by