How to take a given value from a table in a function?

Hello,
For example I have a table given
I calculate a=y/l , For example a=y/l=2 so i need to get g=0.2.
If i get a=y/l=1 (Out of the table) it should be equal g=0.2. Also in the bottom a=y/l=6 => g=0.5.
I did it in function and does not succeed.
Thanks for the helpers
function [g] = func(y, l)
a=y/l
end

 採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 30 日

0 投票

interp1(table_a, table_g, a, 'nearest', 'extrap')

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

タグ

質問済み:

2020 年 12 月 30 日

回答済み:

2020 年 12 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by