aboutsummaryrefslogtreecommitdiffstats
path: root/buch/chapters/80-wahrscheinlichkeit/images/positiv.m
blob: 4dca9504eb3a647bb6e18b9867596ea4e455aa7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# positiv.m
#
# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
#
N = 10;
p = 0.2;

A = eye(3) + p * rand(3,3);
A = [
 1, 0.2, 0.2;
 0.1, 1, 0.1;
 0.05, 0.05, 1
];
B = eye(3);

function retval = punkt(x)
	retval = sprintf("<%.4f,%.4f,%.4f>", x(1), x(3), x(2));
end

fn = fopen("quadrant.inc", "w");
for i = (1:N)
	fprintf(fn, "quadrant(%s,%s,%s)\n",
		punkt(B(:,1)), punkt(B(:,2)), punkt(B(:,3)))
	B = B * A;
end

x = [ 1; 1; 1 ];
for i = (1:100)
	x = A * x;
	x = x / norm(x);
end
fprintf(fn, "eigenvektor(<%.4f, %.4f, %.4f>)\n", x(1), x(3), x(2));


fclose(fn);