# How to create these shapes in Matlab

1 visualización (últimos 30 días)
Nicholas el 21 de Nov. de 2022
Respondida: Image Analyst el 22 de Nov. de 2022
Ive benn trying to complete this assignment with very little luck, here is the code ive managed to write thus far:
filepath1 = '\\myfilepath\\BinaryImage.png';
A = false(100);
figure('Name','Binary images')
subplot(2,2,3) %subplot( no. of rows, no. of cols, position)
for j = 1:100
A(j, 1:(51-j)) = 1;
end
subplot(2,2,3)
imshow(A)
I have attached the question with all the information I have been given.
Any help would be greatly appreciated.
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
DGM el 22 de Nov. de 2022

Iniciar sesión para comentar.

Benjamin Thompson el 21 de Nov. de 2022
Editada: Benjamin Thompson el 21 de Nov. de 2022
Where is the m-file referenced in the problem statement? That would probably help on some of the coding structure questions. You should initially assign a 2D array of ones to A:
A = ones(100,100);
Then based on which row you are updating you need some "if" statements.So if 1 <= j <= 50, you need to zero out the correct number of columns as a function of j. Then it looks like rows 51 to 75 will have a different outcome, then 76 to 100 and 86 to 100 are all treated differently. So at least four different if/else/elseif statements in your for loop to handle the various shapes you are trying to produce as the index variable j increases.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Más respuestas (1)

Image Analyst el 22 de Nov. de 2022
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

R2022b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by