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/exercises/descentfit.m

22 lines
393 B
Matlab

clear
close all
load('lin_regression.mat')
pstart = [-2. 10.];
[params, errors] = descent(x, y, pstart);
figure()
subplot(2,1,1)
hold on
scatter(x, y, 'displayname', 'data')
xx = min(x):0.01:max(x);
fx = params(1)*xx + params(2);
plot(xx, fx, 'displayname', 'fit')
xlabel('Input')
ylabel('Output')
grid on
legend show
subplot(2,1,2)
plot(errors)
xlabel('optimization steps')
ylabel('error')