From 8ea3eaff2ff717af0e75e3fe962260e4ba0f29d1 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 14 May 2023 22:21:04 +0300 Subject: [PATCH] ?? --- linear_regression.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linear_regression.m b/linear_regression.m index 46d8940..9a5795c 100644 --- a/linear_regression.m +++ b/linear_regression.m @@ -8,8 +8,9 @@ y = [2 3 4 5 6]; n = length(x); coeff = [sum(x) n;sum(x) sum(x.^2)]; f_terms = [sum(y);sum(x.*y)]; -results = inv(coeff) * f_terms; +results = coeff \ f_terms; a = results(1); b = results(2); f = a + b * x; plot(x, y,'', x, f); +aaaa = @(x) a*x + bl