How to filter noisy signal using built-in buttord function in Matlab?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Frequency Transformations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!