Help implementing a digital filter
Show older comments
I'm trying to implement a digital filter. I have the coefficients. I make the calculation in a for-loop and it's not working. The results are aberrant = 10^307.
The strange thing is that when I use the BUTTER function and use the returned coefficients, everything works correctly. So, the algorithm is correct.
If I just take the coefficients returned by butter() from workspace and use them in another *.m file as normal variables, it's not working. Why?
If I want to calculate the coefficients and check them in this way, why I cannot do it?
2 Comments
Todd Flanagan
on 21 Jan 2011
Hi. Posting a code snippet would be very helpful.
Monica
on 25 Jan 2011
Answers (1)
Vieniava
on 27 Jan 2011
The problem is that those lines
b = 1.0e-011 *[0.0668 0.3342 0.6683 0.6683 0.3342 0.0668]
a =[ 1.0000 -4.9762 9.9050 -9.8579 4.9055 -0.9765]
are only approximation (for display purpose) of values computed by butter() .
To store your coefficients you should after
[b,a] = butter(5,fc_normal,'low')
write this
save('MyFilter','a','b')
When you need restore those values in another m-file just load via
load MyFilter
Categories
Find more on Analog Filters in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!