From: david t53 on
Hello,

Using filterbuilder, I've designed a filter as follows:
Fpass = 0.45; % Passband Frequency
Fstop = 0.55; % Stopband Frequency
Apass = 1; % Passband Ripple (dB)
Astop = 60; % Stopband Attenuation (dB)
h = fdesign.lowpass('fp,fst,ap,ast', Fpass, Fstop, Apass, Astop);
Hd = design(h, 'butter', 'MatchExactly', 'stopband');

And I get a sosMatrix and scaleVector.
Then I have done a Java program that takes this filter coefficients and runs the filter over an input (ie, it implements the matlab filter function for this case).

However, the coefficients of the filter and the input are in double precission data type.
I need to use 16bits integers, because I actually need to implement the filter in a DSP chip.

Using the filterbuilder, I can specify to use 16 bits integers, and it generates the following m file:
++++++++++++++++++++++++++++++
Fpass = 0.45; % Passband Frequency
Fstop = 0.55; % Stopband Frequency
Apass = 1; % Passband Ripple (dB)
Astop = 60; % Stopband Attenuation (dB)
h = fdesign.lowpass('fp,fst,ap,ast', Fpass, Fstop, Apass, Astop);
Hd = design(h, 'butter', 'MatchExactly', 'stopband');
set(Hd, 'Arithmetic', 'fixed', ...
'InputWordLength', 16, ...
'InputFracLength', 15, ...
'CoeffWordLength', 16, ...
'CoeffAutoScale', true, ...
'SectionInputWordLength', 16, ...
'SectionInputAutoScale', true, ...
'SectionOutputWordLength', 16, ...
'SectionOutputAutoScale', true, ...
'StateWordLength', 16, ...
'StateFracLength', 15, ...
'ProductMode', 'Fullprecision', ...
'AccumMode', 'KeepMSB', ...
'AccumWordLength', 40, ...
'CastBeforeSum', true, ...
'OutputWordLength', 16, ...
'OutputMode', 'Avoidoverflow', ...
'RoundMode', 'convergent', ...
'OverflowMode', 'wrap');
++++++++++++++++++++++++++++++

However, I didn't find information of how to implement the "filter" function in this way (outside matlab, in Java or any other programming language)?
Where can I look info about this?


Best regards,
David