-
Notifications
You must be signed in to change notification settings - Fork 0
/
task4.m
92 lines (80 loc) · 1.84 KB
/
task4.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
clc;
clear;
lambda=50;
a=0.4;
b=0.04;
num_real=20; %number of realizations
s=2;
W=[[0 s];[0 s]];
spacing=0.005;
k=40;
ALXq_avg=zeros(k+1,4);
for i=1:num_real
[M,num_centre]=rBoolRectangles(lambda,a,W,b);
[Pixel]=digitizeDiscSys(M,W,num_centre,spacing);
B=Pixel;
ALXq=estQMinkowskiFcts(B,k,spacing);
ALXq_avg=ALXq_avg+ALXq;
%figure('Y','A')
hold on
figure(1)
plot(ALXq(:,1),ALXq(:,2),'r') %Plot for A
%hold all
%figure('Y','L')
hold on
figure(2)
plot(ALXq(:,1),ALXq(:,3),'r') %Plot for L
%hold all
%figure('Y','X')
hold on
figure(3)
plot(ALXq(:,1),ALXq(:,4),'r') %Plot for X
%hold all
end
ALXq_avg=ALXq_avg/20; %For average value
%figure('Y','A')
hold on
figure(1)
plot(ALXq_avg(:,1),ALXq_avg(:,2),'*') %Plot for A
%hold all
%figure('Y','L')
hold on
figure(2)
plot(ALXq_avg(:,1),ALXq_avg(:,3),'*') %Plot for L
%hold all
%figure('Y','X')
hold on
figure(3)
plot(ALXq_avg(:,1),ALXq_avg(:,4),'*') %Plot for X
%hold all
%For exact solutions
ALXq_exact=[spacing*(0:k).' zeros(k+1,3)];
%display r;
%if r>=0
for i=1:k+1
r=i*spacing;
A(i)=1-exp(-lambda*(r^2+4*(a+b)*r/pi+(a*b)));
L(i)=lambda*(4*r+2*(a+b))*exp(-lambda*(r^2+4*(a+b)*r/pi+(a*b)));
X(i)=(lambda-(lambda^2/(4*pi))*(4*r+2*(a+b))^2)*exp(-lambda*(r^2+4*(a+b)*r/pi+(a*b)));
ALXq_exact(i,1)=r;
ALXq_exact(i,2)=A(i);
ALXq_exact(i,3)=L(i);
ALXq_exact(i,4)=X(i);
end
%end
%figure('Y','A')
hold on
figure(1)
plot(ALXq_exact(:,1),ALXq_exact(:,2),'+') %Plot for A
%hold all
%figure('Y','L')
hold on
figure(2)
plot(ALXq_exact(:,1),ALXq_exact(:,3),'+') %Plot for L
%hold all
%figure('Y','X')
hold on
figure(3)
plot(ALXq_exact(:,1),ALXq_exact(:,4),'+') %Plot for X
%hold all
display(ALXq_exact);