For example i have 5 point like this,
(1,1) (2,-1) (3,2) (4,-2) (5,2)
Now,
- 1) I want a function to interpolation these points in Matlab.
- 2) I want to Plot this function.
- 3) Read a number from input and write F(x) to output.
How can I do this??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To fit a polynom to given datapoints you can use
polyfit(x,y,n)wherexis a vector with points forx,yis a vector with points for y andnis the degree of the polynom. See example at Mathworks polyfit documentationIn your case:
And then to plot, taken from example
Or, to make a prettier plot of the polynomial (instead of above plot)