How to filter noisy signal using built-in buttord function in Matlab?

1 visualización (últimos 30 días)
Hi. I want to filter a noisy signal using built-in function, such as buttord, cheby1 and so on.
%generate the noisy signal which will be filtered
x= cos(2*pi*12*[0:0.001:1.23]);
x(end) = [];
[b a] = butter(2,[0.6 0.7],'bandpass');
filtered_noise = filter(b,a,randn(1, length(x)*2));
x = (x + 0.5*filtered_noise(500:500+length(x)-1))/length(x)*2;
figure(1), plot(x);
title('Noisy signal');
xlabel('Samples');
ylabel('Amplitude');
%plot first half of DFT (normalised frequency)
X_mags = abs(fft(x));
num_bins = length(X_mags);
figure(2),
hold on
plot([0:1/(num_bins/2 -1):1], X_mags(1:num_bins/2))
xlabel('Normalised frequency (\pi rads/sample)')
ylabel('Magnitude')
%Use matlabs built-in buttord function to get the optimum order to meet a specification
[N Wn] = buttord(0.1, 0.5, 5, 40)
%use the N and Wn values obtained above to design the filter in the usual way
[b a] = butter(N, Wn, 'low');
%plot the magnitude spectrum
H = freqz(b,a, floor(num_bins/2));
figure(2);
hold on
plot([0:1/(num_bins/2 -1):1], abs(H),'r');
%filter the signal and plot the output of the filter
x_filtered = filter(b,a,x);
figure(3);
plot(x_filtered);
title(['Filtered Signal - Using ' num2str(N) ' th Order Butterworth']);
xlabel('Samples');
ylabel('Amplitude');
The problem is I don't really know how to identify the values for this code.
[N Wn] = buttord(0.1, 0.5, 5, 40)
How exactly can I know what values should I used? Can somebody help me please?

Respuestas (1)

Star Strider
Star Strider el 14 de Nov. de 2015
To find out what part of your data is likely a valid signal and what part is noise, use the fft function. You have to decide the frequency your cutoff should be. Your design otherwise appears to be correct. For reference, my filter design procedure is here.

Categorías

Más información sobre Frequency Transformations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by