Use MATLAB to find the best a, b, and c coefficients for curve y=a*(sqrt(x)/x)+bx+c to fit
these data points: (x,y)=[(0.1 2.5) (1.2 1.64) (2.1 1.67) (3.35
1.81) (4.5 1.9)]
Use fprintf to show the a,b,c values you obtained, also plot the
points and fitted curve in one plot (use proper labels.)
the matlab script is as follows:
x=[0.1 1.2 2.1 3.35 4.5];
y=[2.5 1.64 1.67 1.81 1.9];
% defining parameters in 1 variable
%c(1)=a;
%c(2)=b;
%c(3)=c;
% defining the non linear curve
F=@(c,xdata) c(1)*(sqrt(xdata)/xdata)+c(2)*xdata+c(3);
% setting up initial value
c0=[0 1 1];
% solver for curve fitting
[c,resnorm,~,exitflag,output] = lsqcurvefit(F,c0,x,y)
fprintf(' the values of coeeficients a,b,c are %d, %d, %d',c(1),c(2),c(3));
plot(x,y,'ro')
title('Data points')
hold on
for i=1:5
y1(i)=F(c,x(i));
end plot(x,y1)
hold off
Get Answers For Free
Most questions answered within 1 hours.