1
votes

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

enter image description here

So I want to apply a

-butterworth filter

-lowpass

  • order n=2

  • cutoff frequency wn= [0,20] Hz

So my doubt is if there is a way to find the residuals by matlab. And then plot them against cutoff frequency.

Any help is huge appreciated.

1

1 Answers

0
votes

You can take your input signal (call it x) and do something like

[b,a]=butter(2, [0 0.3]) % assuming the cutoff is 0.3 times the Nyquist frequency
y = filter(b,a,x)
n = length(x)
z = x - y
z = z.^2
z = sum(z) / n
R = sqrt(z)