Code covered by the BSD License  

Highlights from
MATLAB Contest - blackbox

from MATLAB Contest - blackbox by The MATLAB Contest Team
All the files needed to develop and score an entry for this MATLABĀ® Programming Contest.

drawpuzzle(puzzle,tit)
function [ha,sh] = drawpuzzle(puzzle,tit)

% Copyright 2006 The MathWorks, Inc.

if nargin==1
    tit = ' ';
end
[i,j]=find(puzzle);
[x,y,z] = ellipsoid(0,0,0,.40,.40,.40,50);
n = size(puzzle,1);
clf
figure(gcf)
set(gcf,'MenuBar','none','Name','The Blackbox MATLAB Contest','NumberTitle','off','color','w')
hold on


sh = zeros(numel(i));
for k = 1:numel(i)
    sh(i(k),j(k)) = surf(x+j(k),y+i(k),z+puzzle(i(k),j(k)));
end

set(gca,'Position',[0.05 .03 1 .87])
axis equal
shading interp
axis([0.5-1 n+.5+1 0.5-1 n+.5+1])
set(gca,'Ydir','reverse')
set(gca,'Ytick',[])
set(gca,'Xtick',[])
set(gca,'Ycolor','w')
set(gca,'Xcolor','w')
box off
lightangle(223.1066,58.59)
lighting phong
colorbar
set(gca,'CliMmode','manual')


for i = 1:n
    for j = 1:n
       h = patch([i-.46 i-.46 i+.46 i+.46],[j-.46 j+.46 j+.46 j-.46],[1 1 .93]);
       set(h,'EdgeColor',[.8 .8 .8])
    end
end

ha = gca;
title(tit,'fontsize',14,'Fontweight','bold');
if nargout ==0
    clear ha
end

    

Contact us