Hi,

Im trying to convert from C to MATLAB.

Im a bit stuck with the following code. I need to know what is returned in OverallGainFilter?? This parameter is used elsewhere in the program.

(1) Call the function:

filter_curve_db is a 26 by 2 matrix;Code:float overallGainFilter = interpolate ((float) 1000, filter_curve_db, number_of_points);

number_of_points=26;

(2) The function (interpolation):

Can anyone tell me what is returned in overallGainFilter??Code:float interpolate (float freq, double filter_curve_db [][2], int number_of_points) { double result; int i; double freqLow, freqHigh; double curveLow, curveHigh; if (freq <= filter_curve_db [0][0]) { freqLow = filter_curve_db [0][0]; curveLow = filter_curve_db [0][1]; freqHigh = filter_curve_db [1][0]; curveHigh = filter_curve_db [1][1]; result = ((freq - freqLow) * curveHigh + (freqHigh - freq) * curveLow)/ (freqHigh - freqLow); return (float) result; } if (freq >= filter_curve_db [number_of_points-1][0]) { freqLow = filter_curve_db [number_of_points-2][0]; curveLow = filter_curve_db [number_of_points-2][1]; freqHigh = filter_curve_db [number_of_points-1][0]; curveHigh = filter_curve_db [number_of_points-1][1]; result = ((freq - freqLow) * curveHigh + (freqHigh - freq) * curveLow)/ (freqHigh - freqLow); return (float) result; } i = 1; freqHigh = filter_curve_db [i][0]; while (freqHigh < freq) { i++; freqHigh = filter_curve_db [i][0]; } curveHigh = filter_curve_db [i][1]; freqLow = filter_curve_db [i-1][0]; curveLow = filter_curve_db [i-1][1]; result = ((freq - freqLow) * curveHigh + (freqHigh - freq) * curveLow)/ (freqHigh - freqLow); return (float) result; }

Thanks for any help.