keyboardcowboy
Member level 3
- Joined
- Mar 4, 2010
- Messages
- 55
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,715
I am designing a 9-Tap FIR filter, I have used MATLAB to get the filter coefficients
I have multiplied all the coefficients with a scaling factor to scale them to 16bits. The input to the filter are random 200 values generated by a custom MATLAB code
The maximum value of the sample data is 6.3445 and the minimum value is -7.5099. I am trying to figure out if I should scale the coefficients and the input data using the same scaling factor or should I use separate scaling factor for each. If I should scale both using the same scaling factor then how can I calculate that factor?
Code:
-0.0041 0.0077 0.0893 0.2433 0.3276 0.2433 0.0893 0.0077 -0.0041
I have multiplied all the coefficients with a scaling factor to scale them to 16bits. The input to the filter are random 200 values generated by a custom MATLAB code
Code:
function y4 = sampdata(xlen)
ntaps = 65; % Design filter to make the data band limited.
f = [0.0 0.9 0.95 1.0];
mag = [ 1.0 1.0 0.7071 0.0];
b = fir2(ntaps, f, mag);
a = 1.0;
t = linspace(0,1,floor(xlen/2));
y1 = 5*square(2*pi*2*t);
y2 = filter(b, a, y1);
x = zeros(1,ceil(xlen/2));
for k=1:ceil(xlen/2)
m = (k-1);
t1 = 5*cos(0.1*pi*m + 0.5*pi);
t2 = 2*cos(0.75*pi*m + 0.5*pi);
t3 = 1*cos(0.92*pi*m + 0.5*pi);
x(k) = t1 + t2 + t3;
end
win = transpose(hanning(ceil(xlen/2)));
y3 = win.*x;
y4 = [y2 y3];
return
The maximum value of the sample data is 6.3445 and the minimum value is -7.5099. I am trying to figure out if I should scale the coefficients and the input data using the same scaling factor or should I use separate scaling factor for each. If I should scale both using the same scaling factor then how can I calculate that factor?