How to plot Butterworth filters with own data?

8 views (last 30 days)
Trying to use a bandpass butterworth filter on an ECG signal using the code below but whenever I use the lines:
h= filter( D,C,x) % where x= data
plot(h)
at the end of my code I just get a crazy plot which does not make sense or show my data. How could I accurately plot this filter with my data?
fp= [3 120];
fs= [2 200];
fn= 1000;
[N,fc]= buttord(fp/fn, fs/fn, 1, 60);
[D,C]= butter(N, fc);
%freqz(C,D)
h= filter(D,C,x);
plot(h) % these last 2 lines give strange results

Accepted Answer

Star Strider
Star Strider on 18 Jun 2019
It would help to know the sizes of ‘x’ and ‘h’.
You should also have a time vector, so:
figure
plot(t, h)
grid
will plot ‘h’ as a function of time vector ‘t’.
  4 Comments
Kathleen Nicole Rice
Kathleen Nicole Rice on 19 Jun 2019
Great, this fixed the problem. Thank you so much!

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!