Hi Nuno,
You can use this code to create a random set of dominos in matlab -
% Define the size of the domino tile
tileWidth = 50;
tileHeight = 100;
% Create a figure
figure;
% Define the dot positions for a real domino
dotPositions = {[], [0.5 0.25], [0.3 0.35; 0.7 0.15], [0.3 0.35; 0.5 0.25; 0.7 0.15], ...
[0.3 0.15; 0.3 0.35; 0.7 0.15; 0.7 0.35], ...
[0.3 0.15; 0.3 0.35; 0.5 0.25; 0.7 0.15; 0.7 0.35], ...
[0.3 0.15; 0.3 0.25; 0.3 0.35; 0.7 0.15; 0.7 0.25; 0.7 0.35]};
% Generate a random sequence of dominoes
numTiles = 10;
randomTilesTop = randi([0 6], numTiles, 1);
randomTilesBottom = randi([0 6], numTiles, 1);
% Loop over the number of tiles
for i = 1:numTiles
% Create a rectangle for the tile
rectangle('Position', [i*tileWidth 0 tileWidth tileHeight], 'FaceColor', 'w', 'EdgeColor', 'k');
% Draw a line in the middle of the tile
line([i*tileWidth i*tileWidth+tileWidth], [tileHeight/2 tileHeight/2], 'Color', 'k');
% Draw dots on the top half of the tile
for j = 1:size(dotPositions{randomTilesTop(i)+1}, 1)
% Calculate the position of the dot
x = i*tileWidth + dotPositions{randomTilesTop(i)+1}(j, 1)*tileWidth;
y = dotPositions{randomTilesTop(i)+1}(j, 2)*tileHeight;
% Draw the dot
rectangle('Position', [x-2 y-2 4 4], 'Curvature', [1 1], 'FaceColor', 'k');
end
% Draw dots on the bottom half of the tile
for j = 1:size(dotPositions{randomTilesBottom(i)+1}, 1)
% Calculate the position of the dot
x = i*tileWidth + dotPositions{randomTilesBottom(i)+1}(j, 1)*tileWidth;
y = tileHeight/2 + dotPositions{randomTilesBottom(i)+1}(j, 2)*tileHeight;
% Draw the dot
rectangle('Position', [x-2 y-2 4 4], 'Curvature', [1 1], 'FaceColor', 'k');
end
end
% Adjust the axis
axis equal;
axis off;