MATLAB: How to predict using interpolation or polyfit data acquisitionData Acquisition ToolboxregressionstatisticsStatistics and Machine Learning Toolbox Hi, I have data as below: x y 1.2 2.3 4.8 2.7 5.8 3.5 and I want to predict for x is 2.7, what is y? Many thanks in advance, Best Answer ...Or polyfit function, like:xy = [1.2, 2.3; 4.8, 2.7; 5.8, 3.5];p = polyfit(xy(:,1), xy(:,2), 2);x = linspace(0,6);y = polyval(p, x);figureplot(xy(:,1), xy(:,2),'ro');hold on;plot(x,y,'b:');plot(2.7, polyval(p, 2.7), 'bo');legend({'Data','polyfit','estimated value at x = 2.7'}); Related SolutionsMATLAB: Are these polyfit curves correct Codes are correct%one remark%x2=-8:0.1:8%because the start and endpoint should be similar to x.plot(x,y,'ob'x2,y2,'')%use line markers to distinguish between them :) MATLAB: How to fit a series of datapoints using 3 piecewise linear fit lines Use this FEXload data.mat % attached aboveydata(end) = []; % your xdata/ydata do not match in length ! slope0 = struct('p', 1, 'x', [min(xdata) max(xdata)], 'v', [0 0]);% Download BSFK function here% https://www.mathworks.com/matlabcentral/fileexchange/25872-free-knot-spline-approximationpp = BSFK(xdata,ydata, 2, 3, [], struct('KnotRemoval', 'none', 'pntcon', slope0)); % Checkfigurexi = linspace(min(xdata),max(xdata));yi = ppval(pp,xi)plot(xdata,ydata,'b',xi,yi,'r');for xb=pp.breaks xline(xb);endgrid on Related QuestionHow to extrapolate dataPolynomials fittingLinear regression
Best Answer