This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/regression/code/plotlsqcurvefitpower.m

14 lines
405 B
Matlab

meansquarederrorline; % generate data
p0 = [2.0, 1.0];
pest = lsqcurvefit(@powerLaw, p0, x, y)
hold on;
% generate x-values for plottig the fit:
xx = min(x):0.01:max(x);
yy = powerLaw(xx, pest);
plot(xx, yy); % plot fit
plot(x, y, 'o'); % plot original data
xlabel('Size [m]');
ylabel('Weight [kg]');
legend('fit', 'data', 'location', 'northwest');