Application of the Sptool filter

조회 수: 6 (최근 30일)
Tejas
Tejas 2011년 2월 11일
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

채택된 답변

Vieniava
Vieniava 2011년 2월 11일
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);
  댓글 수: 1
Tejas
Tejas 2011년 2월 11일
Thanks a lot!! Was able to do it...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by