简体   繁体   中英

Fitting a curve and interpolating in Matlab

I have a dataset and I want to fit a curve. The original dataset contains values from 3500 to 4100 with steps of 1.67. I then want to use the fitted curve and find the y2 values for some other x2 values (eg 300 more x2 data). How can I do this in matlab?

在此处输入图片说明

As your plot looks like a simple linear interpolation, you could use

fitfun=@(x) interp1(x2,y2,x,'linear');

to define a function fitfun(x) . Then just call this function with your new x2 values, I think it should work directly with the array (the result will be an array of the same size):

newy2=fitfun(newx2);

Watch out for the bounds: interpolation can't give you points outside the domain set by x2 , unless you tell it what to say (default out-of-bounds value is NaN , I think)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM