MATLAB: Curve Fitting of Data Points

anas

I have lot of data points. I want to make an equation according to the curve formed. But the equations comes from the curve fitting, when I put again in the equation x-point it is not giving corresponding y-point. I am interested to make such equation in which when I put the x-point it would automatically gives the y-points?

Best Answer

This is not parameter estimation (‘curve fitting’) as such, but if you want a way to fit all the points exactly, using the interp1 function with the 'spline' method will work:
N = 50; % Number Of Points
x = 1:N;
y = rand(1, N);
xi = linspace(min(x), max(x), 250);
yi = interp1(x, y, xi, 'spline');
figure(1)
plot(x, y, 'gp')
hold on
plot(xi, yi, '-r')
hold off
grid
Related Question