-
Notifications
You must be signed in to change notification settings - Fork 0
/
LarryMExercise.m
57 lines (46 loc) · 1.01 KB
/
LarryMExercise.m
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
clear, clc, close all
touchAreaX = zeros(10); %touch area
touchAreaY = zeros(10);
for x=1:10
for y=1:10
for n=1:10000
touchAreaX(x,y,n)= x + normrnd(0,4);
end
end
end
for x=1:10
for y=1:10
for n=1:10000
touchAreaY(x,y,n)= y + normrnd(0,4);
end
end
end
figure, hold on
for x=1:10
for y=1:10
scatter(squeeze(touchAreaX(x,y,:)),squeeze(touchAreaY(x,y,:)))
drawnow
end
end
axis equal
%%
award = zeros(10,10,10000);
for x=1:10
for y=1:10
for n=1:10000
if and(touchAreaY(x,y,n) >= 0, touchAreaY(x,y,n) < 10)
if and(touchAreaX(x,y,n) >= 0, touchAreaX(x,y,n) < 5)
award(x,y,n) = -10;
elseif and(touchAreaX(x,y,n) >= 5, touchAreaX(x,y,n) < 10)
award(x,y,n) = 10;
end
end
end
end
end
figure,
surf(mean(award,3));
colorbar
xlabel('x')
ylabel('y')
zlabel('mean award')