MATLAB: How to find curve of best fit or create one manually to fit best fitcurve of best fitparabola angle = [45,50,55,60,65,70,75,80,85]'; P = [55.51, 69.5, 78.07, 82.06, 81.81, 77.3, 68.12, 53.42, 31.59]'; scatter(angle, P, 'bx'); %Also I apparently don't have the cftool so I can't use that I'm afraid. Best Answer It looks like a parabols. If you have optimization toolbox, you can use lsqcurvefit to fit this equation (y=a*x^2+b*x+c) to the dataset.angle = [45,50,55,60,65,70,75,80,85]';P = [55.51, 69.5, 78.07, 82.06, 81.81, 77.3, 68.12, 53.42, 31.59]';fun = @(a,b,c,angles) a*angles.^2 + b.*angles + c;param_sol = lsqcurvefit(@(param, angles) fun(param(1),param(2),param(3),angles), rand(1,3), angle, P);a_sol = param_sol(1);b_sol = param_sol(2);c_sol = param_sol(3);plot(angle, P, 'bx', angle, fun(a_sol, b_sol, c_sol, angle), 'r-');You can also do it without any toolbox. Following also fit a parabolic equation of form (y=a*x^2+b*x+c)angle = [45,50,55,60,65,70,75,80,85]';P = [55.51, 69.5, 78.07, 82.06, 81.81, 77.3, 68.12, 53.42, 31.59]';X = [angle(:).^2 angle(:) ones(size(angle(:)))];params = X\P(:);P_estimated = X*params;plot(angle, P, 'bx', angle, P_estimated, 'r-') Related SolutionsMATLAB: How to decrease the number of points in a matrix I suggest http://www.mathworks.com/help/matlab/ref/spline.htmlx = 1 : length(psdn);x128 = linspace(x(1), x(end), 128);p128 = spline(x, psdn, x128);plot(x128, p128); MATLAB: Can someone please help me solve this differential equation using MATLAB? dP/dt = k*P*ln(450/P) where k is an unknown constant. Given initial conditions are P(0)=40, and P(15)=95 syms P(t) ksol_P = dsolve(diff(P,t) == k*P*log(450/P), P(0)==40)sol_k = solve( subs(sol_P, t, 15) == 95 );simplify(subs(sol_P, k, sol_k)) Related QuestionI cannot create that array in Matlab !Help solve a system of Differential EquationsWhat proportion of students failed the course (i.e., got a mark of less than 50)Conversion of Matrix dimensionsHow to fit an integral with data points in Matlab, where the integration limit can vary
Best Answer