draw min squares in black and white

3 visualizaciones (últimos 30 días)
Ahmed raafat
Ahmed raafat el 27 de Mayo de 2016
Editada: Roger Stafford el 28 de Mayo de 2016
Hi every
I want to plot min squares in black and white like the attachment
I had an idea (I didn't try it that i make the 3-dim image matrices)
Is there other solutions???
  3 comentarios
Ahmed raafat
Ahmed raafat el 27 de Mayo de 2016
I mean with like a grid with square size 1cm*1cm
And it is a task
Ahmed raafat
Ahmed raafat el 27 de Mayo de 2016
Please see the attachment to understand me of min squares

Iniciar sesión para comentar.

Respuesta aceptada

Roger Stafford
Roger Stafford el 27 de Mayo de 2016
Do the following:
m = 16; n = 33;
A = false(m,n);
A(1,17) = true;
for k = 2:m
v = 2:n-1;
A(k,v) = A(k-1,v-1)~=(A(k-1,v)|A(k-1,v+1));
end
Then use the A(:,2:n-1) matrix to determine which squares are to be black (true) and which are white (false.) I’ll leave the plotting up to you.
  2 comentarios
Ahmed raafat
Ahmed raafat el 28 de Mayo de 2016
Thanks mr.Roger
It worked
Roger Stafford
Roger Stafford el 28 de Mayo de 2016
Editada: Roger Stafford el 28 de Mayo de 2016
It should be noted here that your “rule 30” presumably refers to a logic method devised by Stephen Wolfram for generating a pseudo-random sequence of binary digits. The “30” refers to the binary representation of the truth table involved: 00011110.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 28 de Mayo de 2016
Seems like homework, so here's a hint. Look at the pattern. The three binary squares above are 7, 6, 5, 4, 3, 2, 1, 0. You just need to turn the three elements above the current element into a decimal number like
decNumber = 4*A(row-1, col-1) + 2*A(row-1, col) + A(row-1, col+1);
Then if decNumber is 1 through 4 inclusive, then set the value to 1, otherwise it's zero.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by