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/projects/project_input_resistance/solution/gradientDescent.m

14 lines
354 B
Matlab

function [position, errors] = gradientDescent(x, y, position)
gradient = [];
errors = [];
count = 1;
eps = 0.02;
close all
while isempty(gradient) || norm(gradient) > 0.025
gradient = lsqGradient(position, x,y);
% disp(gradient)
errors(count) = lsqError(position, x, y);
position = position - eps .* gradient';
count = count + 1;
end