I have 2 arrays, one with distances and one with heigth.
heigth = [10 20 30 40]
distance = [1 2 3 4]
I want to be able to get the heigth at any given value from 1 to 4. The main idea is to be able to do:
getHeigth(1.5) --> 15

 採用された回答

Thomas Koelen
Thomas Koelen 2015 年 5 月 13 日

1 投票

interp1(height,distance,heightinput)

1 件のコメント

ricard molins
ricard molins 2015 年 5 月 13 日
The solution is correct although I asked for interpolating heigth when introducing the distance. It's just need to swap the arguments.
Thanks for your answer

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

その他の回答 (2 件)

Purushottama Rao
Purushottama Rao 2015 年 5 月 13 日

0 投票

c= fit([1; 2; 3 ;4],[10 ;20; 30; 40],'poly2')

1 件のコメント

Purushottama Rao
Purushottama Rao 2015 年 5 月 13 日
Later u can call c(1.5) results in 15

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by