MATLAB: How to plot Butterworth filters with own data

butterworthecgfilterMATLAB

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

Best Answer

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’.
Related Question