moving filter average with convolutional function
12 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Image Analyst
on 15 Feb 2022
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);
More Answers (1)
Benjamin Thompson
on 15 Feb 2022
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)
See Also
Categories
Find more on Single-Rate Filters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!