How do I create a lookup-table for values interpolated from existing data?

14 visualizzazioni (ultimi 30 giorni)
I need to build a Gain curve which has couple points in dB domain such as { -48, 3 } , { -36, 9 } , { -24, 9 } , { 0, -7 }. Based on audio signal frame power (in dB), I could search for appropriate gain from the table. As there are just few points as written above, I need to interpolate the correct gain every time as the power is usually between the points. Is there a readymade solution from MATLAB for doing so?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 17 Gen 2025
Modificato: MathWorks Support Team il 31 Gen 2025
MATLAB has a built-in function called "interp1" for interpolating data which can be used in this workflow.
Refer to the example below for how to use the "interp1" function.
>> input_dB = [-48, -36, -24, 0]; >> output_dB = [3, 9, 9, -7]; >> desired_input_dB = [-40, -30, -20, -10];
% Returns interpolated output values at desired input values >> interp_output_dB = interp1(input_dB, output_dB, desired_input_dB, 'linear');
The above code uses the linear interpolation method. If you are interested in other methods, you can access more details on "interp1" by running the following command in the MATLAB R2020a command window:
>> web(fullfile(docroot, 'matlab/ref/interp1.html'))
To create a table with the new data, use the table function as shown below,
>> t = table(desired_input_dB', interp_output_dB', 'VariableNames', {'Input', 'Output'});
For more about the "table" function, you can refer to the documentation by executing the following command in the MATLAB R2020a command window:
>> web(fullfile(docroot, 'matlab/ref/table.html'))
Please follow the below link to search for the required information regarding the current release:

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by