MATLAB Answers

Oila R
0

Finding approximate y values for corresponding x values in matlab

Asked by Oila R
on 31 May 2019
Latest activity Answered by Fangjun Jiang on 31 May 2019
Suppose I have a graph (formed from data) that has x and y values, but it is not analytic (so not continuous). I need to find a way such that for any x value, matlab will find the closest x value on the graph and give me the corresponding y value. Any ideas?
for example:
x y
1 2
2 5
3 8
4 13
5 23
6 49
So say that is my function, and I want to find the y value that corrisponds to x = 3.1 or 5.2, etc. The data is weird so I cant to a trivial linear approximation or something like that for the whole graph.

  0 Comments

Sign in to comment.

1 Answer

Answer by Fangjun Jiang on 31 May 2019

interp1(x,y,3.1,'nearest')

  0 Comments

Sign in to comment.