-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgauss.m
56 lines (55 loc) · 1.99 KB
/
gauss.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
function res=gauss(xc,yc,sigma,map_s,type)
res=zeros(map_s,map_s);
for x=1:map_s
for y=1:map_s
if(x>0 && y>0 && x<=map_s && y<=map_s)
if(type==2)
d = sqrt((x-xc).^2 + (y-yc).^2);
t = 20;
if(d>t)
res(x,y) = t*d-0.5*(t).^2;
else
res(x,y) = 0.5*(d).^2;
end
res(x,y) = 0.000001*res(x,y);
%res(x,y) = -( 3*min(sqrt(1/((x-xc).^2 + (y-yc).^2)) , *** ) );
%amplitude = -(amplitude);
%end
else
if(type == 3)
%if(x>0 && y>0 && x<=map_s && y<=map_s)
% exponent = ((x-xc).^2 + (y-yc).^2)./(2*sigma^2);
% amplitude = 1 / (sigma * sqrt(2*pi));
% res(x,y)= 1.5*amplitude * exp(-exponent);
a = 2;
b = 2;
thr= 5;
c = ( (x-xc).^2 )/a.^2 +( (y-yc).^2 )/b.^2 ;
c = sqrt(c);
if(c < 1)
res(x,y) = min( (1 - 1/c).^2 ,thr);
res(x,y) =res(x,y)*0.001;
else
res(x,y)=0;
end
else
if(type==1)
res(x,y)=0;
else
a = 300;
b = 300;
thr= 5;
c = ( (x-xc).^2 )/a.^2 +( (y-yc).^2 )/b.^2 ;
c = sqrt(c);
if(c < 1)
res(x,y) = min( (1 - 1/c).^2 ,thr);
res(x,y) =res(x,y)*0.001;
else
res(x,y)=0;
end
end
end
end
end
end
end