The problem is in calculating term_0 and term_1, I tried to search for the error but found nothing useful.
syms k;
x = [100, 120, 130, 140, 150];
w = 7000;
y = w * x;
t0 = 0;
t1 = 0;
a = 0.8;
m = 5;
term_0 = (a/m) * symsum(t0 + t1*x(k) - y(k),k, 0, m);
term_1 = (a/m) * symsum((t0 + t1*x(k) - y(k)) * x(k),k, 0, m);
while True
temp0 = t0 - term_0;
temp1 = t1 - term_1;
if temp0 == t0 && temp1 == t1
break;
end
t0 = temp0;
t1 = temp1;
end
h = t0 + t1*x;
hold on;
plot(x, y,'xb');
plot(x, h, 'r');
hold off;