summaryrefslogtreecommitdiff
path: root/845/CH5/EX5.5/Ex5_5.sce
blob: 0c5c5eccd07bcbaac63ccf442e839f7436bec232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Example 5.5

clc
clear

x = 1:6;
y = [2.6 5.4 8.7 12.1 16 20.2];

X = x;
Y = y ./x;

n = length(Y);
M1 = [sum(Y); sum(X.*Y)];
M2 = [n sum(X); sum(X) sum(X.^2)];

A = M2\M1;

a = A(1);
b = A(2);

disp(round(a*10^5)/10^5, "a =")
disp(round(b*10^5)/10^5, "b =")