-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotmap.m
More file actions
executable file
·59 lines (50 loc) · 1.22 KB
/
plotmap.m
File metadata and controls
executable file
·59 lines (50 loc) · 1.22 KB
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
function plotmap(map,steps)
%Plots the map. See map_convert
[X,Y]=meshgrid(1:20,1:20);
plot(X,Y,'k'); hold on
plot(Y,X,'k');
axis([0, 20, 0, 16]);
axis off
[maprows,mapcols]=size(map);
for i=1:maprows,
for j=1:mapcols,
if (map(i,j) == 1)
placeblock([16-i,j]);
end;
end
end
%plot row indices
for i = 1:maprows,
c=sprintf('%d',i);
text(0.5,maprows-i+1+0.5,c,'FontSize',8);
text(mapcols+1+0.5,maprows-i+1+0.5,c,'FontSize',8);
end
%plot col indices
for i = 1:mapcols,
c=sprintf('%d',i);
text(0.5+i,maprows+1+0.5,c,'FontSize',8);
text(0.5+i,0.5,c,'FontSize',8);
end
if (nargin == 2)
if (length(steps)>0),
for i=1:length(steps),
placestep([16-steps(i,1) steps(i,2)],i);
end
end
end
hold off
end
function placeblock(position)
position=[position(2) position(1)];
rectangle('Position',[position,1,1],'FaceColor','r');
end
function eraseblock(position)
position=[position(2) position(1)];
rectangle('Position',[position,1,1],'FaceColor','w');
end
function placestep(position,i)
position=[position(2)+0.1 position(1)+0.1];
rectangle('Position',[position,0.8,0.8],'FaceColor','y');
c=sprintf('%d',i);
text(position(1)+0.2,position(2)+0.2,c,'FontSize',10);
end