Code covered by the BSD License

# Mathworks Rubik version 2

### Thomas Beneder (view profile)

04 Apr 2013 (Updated )

Display, tester and solver of the Rubik's game, including "full cubes".

ShowTitle(hAxes,Cube,iSol)
```function ShowTitle(hAxes,Cube,iSol)
%ShowTitle - Shows the title of the Rubiks axes
%   ShowTitle(hAxes,Cube[,iSol])
%      with iSol the index in the solution list
%      if not given, Cube.iSol is used.

if nargin<2
if nargin<1
hAxes=FindRubikAxes;
end
Cube=get(hAxes,'UserData');
end
if isempty(Cube.sol)
s='';
else
n=size(Cube.sol,1);
if nargin<3
iSol=min(n,Cube.iSol);
end
sol=Cube.sol(max(1,iSol):min(end,iSol+1),:);
if isempty(Cube.texture)
%CCols={'rood','oranje','blauw','groen','geel','wit'};
CCols=cell(1,6);
for i=1:6	% (!!)only one or two colors are necessary
c=Cube.ValColor(i+1,:);
if all(c==[0 0 0])
CCols{i}='black';
elseif all(c==[1 1 1])
CCols{i}='white';
elseif all(c==[1 0 0])
CCols{i}='red';
elseif all(c==[0 1 0])
CCols{i}='green';
elseif all(c==[0 0 1])
CCols{i}='blue';
elseif all(c==[1 1 0])
CCols{i}='yellow';
elseif all(c==[1 0 1])
CCols{i}='magenta';
elseif all(c==[0 1 1])
CCols{i}='cyan';
elseif c(1)>0.95&abs(c(2)-0.5)<0.1&c(3)<0.1
CCols{i}='orange';
else
CCols{i}='unkowncolor';
end
end
else
sol1=Color2FRU(sol,Cube);
sol(:,1)=sol1(:,1)*2+(sol1(:,2)+1)/2-1;
CCols={'Back','Front','Left','Right','Down','Up'};
end
if iSol==0
s=sprintf('  0/%3d :           - next %-6s %2d',n,CCols{sol(1,1)},sol(1,2));
elseif iSol==n
s=sprintf('%3d/%3d : %-6s %2d',iSol,n,CCols{sol(1,1)},sol(1,2));
else
s=sprintf('%3d/%3d : %-6s %2d - next %-6s %2d',iSol,n,CCols{sol(1,1)},sol(1,2),CCols{sol(2,1)},sol(2,2));
end
end
set(get(hAxes,'Title'),'String',s)
```