moving filter average with convolutional function
12 次查看(过去 30 天)
显示 更早的评论
For question 2i, I am confused that question, I have understanded in 2 ways:
firstly, we take N as a vector and find y[n] by con(1./N,ecg)
secondly, we take each number of N and multiplies to conv(ecg, h) with h is delta function.
Which way is correct?
Thank you so much for your answer
0 个评论
采纳的回答
Image Analyst
2022-2-15
No, N is not a vector it's a number, though you can make a vector from all the Ns:
allN = [2, 4, 8, 16, 32];
plot(ecg, 'b-', 'LineWidth', 3);
grid on;
for k = 1 : length(allN)
% Get this one N
N = allN(k);
% Construct kernel
h = ones(1, N) / N;
% Do the convolution, cropping to the same size as the input vector.
output = conv(ecg, h, 'same');
% Plot it.
hold on;
plot(output, '-');
% Create the string for the legend since all plots show up in different colors.
legendStrings{k} = sprintf('N = %2.2d', N);
end
legend(legendStrings);
更多回答(1 个)
Benjamin Thompson
2022-2-15
Are you asking how to define h in MATLAB?
>> h = ones(8,1)/8
h =
0.1250
0.1250
0.1250
0.1250
0.1250
0.1250
0.1250
0.1250
Then if you have an input signal ecf you can call conv(h, ecg)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Single-Rate Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!