MATLAB Answers

0

How can I get the interpolated value of and array

Asked by ricard molins on 13 May 2015
Latest activity Commented on by ricard molins on 13 May 2015
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

  0 Comments

Sign in to comment.

3 Answers

Answer by Thomas Koelen on 13 May 2015
 Accepted Answer

interp1(height,distance,heightinput)

  1 Comments

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

Sign in to comment.


Answer by Michael Haderlein on 13 May 2015

>> doc interp1

  0 Comments

Sign in to comment.


Answer by Purushottama Rao on 13 May 2015

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

  1 Comments

Later u can call c(1.5) results in 15

Sign in to comment.



Translated by