butterworth residuals vs cutoff frequency

9 views (last 30 days)
i need to apply a butterworth filter. to prove my cutoff frequency i need to do a plot ''residuals vs cutoff frequency'' like in the 2nd sqare of the picture. . residuals come from http://oi47.tinypic.com/21eokqr.jpg
so i want to apply a
-butterworth filter
-lowpass
- order n=2
- cutoff frequency wn= [0,20] hz
so my doubt is if there ia a way to find the residuals by matlab. and then plot them against cutoff frequency.
any help is huge appreciated. thank you so much
  1 Comment
Jan
Jan on 26 Nov 2012
A lowpass-filter has a scalar wn frequency. For a [1 x 2] frequency a bandpass or bandstop filter is created.

Sign in to comment.

Accepted Answer

Wayne King
Wayne King on 26 Nov 2012
Edited: Wayne King on 26 Nov 2012
You can certainly subtract the filtered waveform from the original and plot the spectrum of that difference signal. For that you should use filtfilt() to compensate for the delay.
You do not tell us your sampling frequency, so I'll just assume 1000 for this example.
x=ecg(500)'+0.25*randn(500,1); %noisy waveform
[B,A] = butter(2,20/(1000/2));
xprime = filtfilt(B,A,x);
resid = x-xprime;
Your slide seems to suggest forming the following test statistic for various values of the cutoff frequency and examining R.
wc = [10:30]./(1000/2);
for nn = 1:length(wc)
[B,A] = butter(2,wc(nn));
xprime = filtfilt(B,A,x);
resid = x-xprime;
R(nn) = sqrt(1/length(x)*(sum(abs(x-xprime).^2)));
end
  4 Comments
Wayne King
Wayne King on 26 Nov 2012
For one thing, if your sampling frequency is 40 Hz, then the cutoff frequency of 0.2 is only 4 Hz. Do you really want to limit yourself to such a low frequency here. And why start at 0? You have to keep in mind that butter() accepts normalized frequencies.
Personally, I pick the cutoff frequency based on what I know about the data and what part of the spectrum I want to focus on.
joo
joo on 26 Nov 2012
i am sorry but i really don't understand nothing from frquencies. that 's why i want to do this plot to justificate them. i want to star at 0 to obtain a plot like http://oi47.tinypic.com/21eokqr.jpg
thank you so much for all your help and please if you can help me with the new question i am very grateful

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!