Borrar filtros
Borrar filtros

moving filter average with convolutional function

10 visualizaciones (últimos 30 días)
Tu Nguyen
Tu Nguyen el 15 de Feb. de 2022
Comentada: Tu Nguyen el 16 de Feb. de 2022
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

Respuesta aceptada

Image Analyst
Image Analyst el 15 de Feb. de 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);

Más respuestas (1)

Benjamin Thompson
Benjamin Thompson el 15 de Feb. de 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)

Community Treasure Hunt

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

Start Hunting!

Translated by