-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdrawPattern.m
More file actions
35 lines (31 loc) · 2.28 KB
/
Copy pathdrawPattern.m
File metadata and controls
35 lines (31 loc) · 2.28 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
function drawPattern(IM)
% This function draws the pattern beautifully
% the pattern can be given as a square matrix
% or it can be given as a horizontal or vertical vector
% example:
% drawPattern(X(120,:));
% drawPattern(Xtest); % where size(Xtest)=[1,N^2]
%
% written by: Mehrdad Honarkhah
[sz1,sz2] = size(IM);
if sz1==1 || sz2==1
sz=sqrt(sz1+sz2-1); % pattern dimension
IM=reshape(IM, sz, sz);
else
sz = sz1;
end
figure1 = figure('Renderer','painters','Colormap',[0.23 0.23 0.23;0.2422 0.2422 0.2422;0.2544 0.2544 0.2544;0.2667 0.2667 0.2667;0.2789 0.2789 0.2789;0.2911 0.2911 0.2911;0.3033 0.3033 0.3033;0.3156 0.3156 0.3156;0.3278 0.3278 0.3278;0.34 0.34 0.34;0.3522 0.3522 0.3522;0.3644 0.3644 0.3644;0.3767 0.3767 0.3767;0.3889 0.3889 0.3889;0.4011 0.4011 0.4011;0.4133 0.4133 0.4133;0.4256 0.4256 0.4256;0.4378 0.4378 0.4378;0.45 0.45 0.45;0.4622 0.4622 0.4622;0.4744 0.4744 0.4744;0.4867 0.4867 0.4867;0.4989 0.4989 0.4989;0.5111 0.5111 0.5111;0.5233 0.5233 0.5233;0.5356 0.5356 0.5356;0.5478 0.5478 0.5478;0.56 0.56 0.56;0.5722 0.5722 0.5722;0.5844 0.5844 0.5844;0.5967 0.5967 0.5967;0.6089 0.6089 0.6089;0.6211 0.6211 0.6211;0.6333 0.6333 0.6333;0.6456 0.6456 0.6456;0.6578 0.6578 0.6578;0.67 0.67 0.67;0.6822 0.6822 0.6822;0.6944 0.6944 0.6944;0.7067 0.7067 0.7067;0.7189 0.7189 0.7189;0.7311 0.7311 0.7311;0.7433 0.7433 0.7433;0.7556 0.7556 0.7556;0.7678 0.7678 0.7678;0.78 0.78 0.78;0.7922 0.7922 0.7922;0.8044 0.8044 0.8044;0.8167 0.8167 0.8167;0.8289 0.8289 0.8289;0.8411 0.8411 0.8411;0.8533 0.8533 0.8533;0.8656 0.8656 0.8656;0.8778 0.8778 0.8778;0.89 0.89 0.89;0.9022 0.9022 0.9022;0.9144 0.9144 0.9144;0.9267 0.9267 0.9267;0.9389 0.9389 0.9389;0.9511 0.9511 0.9511;0.9633 0.9633 0.9633;0.9756 0.9756 0.9756;0.9878 0.9878 0.9878;1 1 1]);
axes1 = axes('Parent',figure1,'YTick',zeros(1,0),'XTick',zeros(1,0),...
'PlotBoxAspectRatio',[1 1 1],...
'MinorGridLineStyle','none',...
'LineWidth',3,...
'Layer','top',...
'GridLineStyle','none');
box('on');
hold('all');
temp = zeros(sz+1);
temp(1:sz,1:sz)=IM;
surf(temp,'Parent',axes1,'MarkerSize',2,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor',[0 0 0],'Marker','+','LineWidth',1.25);
axis([1 sz+1 1 sz+1])
view(0,-90)
end