MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by vipul utsav on 29 Nov 2012

i have two array x=[1 6 8 9],y=[3 6 9 14],then i plot (x,y) in matlab. i have no linear equation of x,y. i have only above array of x and y. if value of x is 4 then what is the value of y.

is it possible using logic?

*No products are associated with this question.*

Answer by Matt Fig on 29 Nov 2012

Accepted answer

x=[1 6 8 9]; y=[3 6 9 14]; interp1(x,y,4,'linear')

Show 1 older comment

Matt Fig on 29 Nov 2012

Use the same approach, simply with the new values. You can use any of the interpolating methods available int INTERP1. Have a look at the help:

help interp1

vipul utsav on 29 Nov 2012

yes i read help,but for 11 inter11 doesn't work. and for 4 it is work. 11 is outside of maximum value in x.

Matt Fig on 29 Nov 2012

If you read the help, you would see there is an extrapolation option. When you want to look at values outside the range, you are extrapolating. You should also know that extrapolating is usually something one does not want to do for real applications.... especially for so sparsely populated data as this!

interp1(x,y,11,'linear','extrap')

If your original question has been answered, please accept the answer.

Answer by Jan Simon on 29 Nov 2012

Edited by Jan Simon on 29 Nov 2012

There is an infinite number of possible values: You can e.g. define an infinite number of polynomials through these points. And there are much more functions than only polynomials.

Therefore this problem cannot be solved, when there are no further restrictions.

One workaround would be to choose 19. This is not really serious, but fast and it solves the question as good as any other value also. The choice of 19 is explained in Carl E. Liderholm: "Mathematics Made Difficult", 1972:

Each sequence of natural number can be continued by 19.

## 4 Comments

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/55169#comment_114320

what do you mean by logic? almost same question at http://www.mathworks.com/matlabcentral/answers/55165-i-have-two-array-x-1-6-8-9-y-3-6-9-14-then-i-plot-x-y-in-matlab-i-have-no-linear-equation-of

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/55169#comment_114321

please be clear with you question ,, what exactly do u require or to execute?

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/55169#comment_114323

'interp1' this is inbuilt function ,so i just want logic behind it

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/55169#comment_114326

What result are you expecting?