MATLAB: How to resample from the data in MATLAB

Curve Fitting Toolbox

I have 1000 data points (X,Y) in my testing curve.
What function in MATLAB can I use to condense it to 100 data points?

Best Answer

You can use the "fit" function from our Curve Fitting toolbox to fit a curve to your data and then use the fitted curve to sample a new set of data:
>> % Generate 100 random data points
>> x1 = [-50:50]';
>>y1 = x1.^2 + 200.*randn(numel(x1),1);
>>
>> % fit a curve
>>f = fit(x1, y1, 'poly2');
>>
>> % subset of data, from the fitted curve
>>x2 = -25:25;
>>y2 = f(x2);
>>
>>figure
>>plot(x1,y1,'o')
>>hold on
>>plot(x2, y2,'x')
You can refer to the following documentation link to learn more about the "fit" function used above :