Borrar filtros
Borrar filtros

Combine block matrix with same elements

1 visualización (últimos 30 días)
Hoang Vu Huy
Hoang Vu Huy el 5 de Abr. de 2022
Comentada: Voss el 5 de Abr. de 2022
I want to creat matrix:
7 7 7 7 7 2 2
7 7 7 7 7 2 2
6 6 9 9 9 2 2
6 6 9 9 9 2 2
6 6 8 8 8 8 8
6 6 8 8 8 8 8
I used code:
[zeros(2,5)+7zeros(2,2)+2;zeros(2,2)+6,zeros(2,3)+9,zeros(2,2)+2;zeros(2,2)+6,zeros(2,5)+8]
But i think have a different way to creat it. That way use matrix which has same element.

Respuesta aceptada

Voss
Voss el 5 de Abr. de 2022
Editada: Voss el 5 de Abr. de 2022
A = [7 7 2; 6 9 2; 6 8 8]
A = 3×3
7 7 2 6 9 2 6 8 8
repelem(A,[2 2 2],[2 3 2])
ans = 6×7
7 7 7 7 7 2 2 7 7 7 7 7 2 2 6 6 9 9 9 2 2 6 6 9 9 9 2 2 6 6 8 8 8 8 8 6 6 8 8 8 8 8
  2 comentarios
Hoang Vu Huy
Hoang Vu Huy el 5 de Abr. de 2022
Thank you very much
Voss
Voss el 5 de Abr. de 2022
You're welcome!
If my answer is what you wanted to do, please click Accept This Answer. Otherwise, if you had a different idea in mind, please let me know. Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by