We are interested in creating a grid of n boxes by n boxes. Each box in the grid is 5 x 5 pixels and the surrounding black border is 1 pixel thick. The second last row and the second last column of the boxes are of cyan color (RGB = [0, 255, 255]), rest all are white. Write a program which displays such a grid based on the number of boxes given by the user. Assume that the user will always input a value greater than 4.

Respuesta :

Answer:

clc

clear

size = input('Enter the number of boxes in a row : ');

for i=1:size

for j=1:size

if i==size-1 || j==2

rectangle('Position',[i*size,j*size,size,size],'FaceColor',[0,1,1],'EdgeColor','black',...

'LineWidth',3)

else

rectangle('Position',[i*size,j*size,size,size],'FaceColor',[1 1 1],'EdgeColor','black',...

'LineWidth',3)

end

end

end

Explanation:

Ver imagen akindeleot
Ver imagen akindeleot