How do I create a lookup-table for values interpolated from existing data?
조회 수: 14 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2020년 12월 30일
편집: MathWorks Support Team
2025년 1월 31일
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?
채택된 답변
MathWorks Support Team
2025년 1월 17일
편집: MathWorks Support Team
2025년 1월 31일
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:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!