Create Lookup Table in Matlab

41 ビュー (過去 30 日間)
Sherif Elkholy
Sherif Elkholy 2017 年 5 月 13 日
コメント済み: Sherif Elkholy 2017 年 5 月 13 日
Hi, I want to create lookup table in Matlab that contains angle in radians and power value corresponding to it. The main code will have an angle which will be looked for in the lookup table and return the corresponding power value. I want to use linear interpretation to calculate the angles values that are not present in the table. Can you please help? Thanks

採用された回答

Image Analyst
Image Analyst 2017 年 5 月 13 日
Try interp1:
allAngles = linspace(0, 2*pi, 10000); % 10 thousand elements in the look up table.
powerLut = interp1(angles, powers, allAngles);
anglesis the array that has however many angle values that you have to begin with. Same for powers - it's the corresponding power for each of those angles. Be aware that you have to determine the index and not just put in some floating point angle into the look up table, so it needs to be an integer between 1 and 10 thousand.
  1 件のコメント
Sherif Elkholy
Sherif Elkholy 2017 年 5 月 13 日
Thanks. I will try it this afternoon.

サインインしてコメントする。

その他の回答 (1 件)

Les Beckham
Les Beckham 2017 年 5 月 13 日
As Image Analyst said, I think interp1 is the way to go. However, I would just call it with the specific angle for which you want the power value:
currentAngle = pi/4; % for example
currentPower = interp1(angles, powers, currentAngle); % returns the power value corresponding to currentAngle
This, of course, assumes that you know the power values (powers) for some specific set of angle values (angles). These two known vectors constitute your lookup table. Check the doc for interp1 for more info.
  1 件のコメント
Sherif Elkholy
Sherif Elkholy 2017 年 5 月 13 日
Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLookup Tables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by