Application of the Sptool filter
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all, As a part of my project, i require a lowpass filter of cut off frequency 50 Hz. This I was able to design using the SPTOOL in matlab.The designed filter was an IIR Butterworth filter.My problem is the fact that I want to use the generated filter in my code.Currently, what I do to use the filter is that I import the signal to be filtered from the matlab workspace to sptool, apply the filter to it and export it back to the workspace.However, I dont want the GUI but want that filter to be applied in my code itself.The m file generated contains objects and such which I am not familiar with.The important thing for me right now is how to use the generated m file of the filter on the array .Is it possible to do such a thing?Thanks in advance
0 commentaires
Réponse acceptée
Vieniava
le 11 Fév 2011
Your generated mfile suppose to look like this
%UNTITLED Returns a discrete-time filter object.
% M-File generated by MATLAB(R) 7.8 and the Signal Processing Toolbox 6.11.
%
% Generated on: 11-Feb-2011 13:01:59
%
% Butterworth Lowpass filter designed using FDESIGN.LOWPASS.
% All frequency values are in Hz.
Fs = 48000; % Sampling Frequency
Fpass = 9600; % Passband Frequency
Fstop = 12000; % Stopband Frequency
Apass = 1; % Passband Ripple (dB)
Astop = 80; % Stopband Attenuation (dB)
match = 'stopband'; % Band to match exactly
% Construct an FDESIGN object and call its BUTTER method.
h = fdesign.lowpass(Fpass, Fstop, Apass, Astop, Fs);
Hd = design(h, 'butter', 'MatchExactly', match);
% [EOF]
Now you should copy those lines into your script:
Fs = 48000; % Sampling Frequency
Fpass = 9600; % Passband Frequency
Fstop = 12000; % Stopband Frequency
Apass = 1; % Passband Ripple (dB)
Astop = 80; % Stopband Attenuation (dB)
match = 'stopband'; % Band to match exactly
h = fdesign.lowpass(Fpass, Fstop, Apass, Astop, Fs);
Hd = design(h, 'butter', 'MatchExactly', match);
Dont be afraid of objects. Filtering is simple now, you can use Hd filter object whenever you need to filter any signal:
Sfiltered=filter( Hd, S);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Digital Filtering 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!