dritech
dritech

Reputation: 85

MATLAB filter code

I designed an FIR filter (highpass) in the FDAtool. Now I have a sine wave created using MATLAB code which I need to pass from the filter to monitor its performance. To generate the filter design code I selected: File > generate MATLAB code > MAT-file. Is this the correct way to do it? After the code is generated, how can I use it with the sine wave?

Thanks in advance for any kind of help.

Upvotes: 0

Views: 524

Answers (1)

patrik
patrik

Reputation: 4558

If it works, it is not wrong. You want to store the code in a .m file though. You can run the function then to create your filter object. You can also make it more dynamic if you want by editing the function (like add input arguments to let it work for other frequencies or sampling frequencies as well). To confirm it works as it should you can use freqz to se the digital frequency response. To filter a signal then, you can use filter.

yFilt = filter(Hd, y0);

where y0 is the original signal yFilt the filtered signal and Hd the filter object. You can try the filter with white noise as well. The frequency response for AWGN should be the same as the filter's frequency response.

Upvotes: 2

Related Questions