Borrar filtros
Borrar filtros

How can i create this specific matrix??

1 visualización (últimos 30 días)
연승 김
연승 김 el 9 de Sept. de 2021
Comentada: 연승 김 el 9 de Sept. de 2021
Hello. I'm MATLAB beginner.
I want to make A matrix like below.
ex1)
i = 2
j = 3
A = [1,1,0,0,0,0 ; 0,0,1,1,0,0 ; 0,0,0,0,1,1]
ex2)
i = 2
j = 2
A = [1,1,0,0 ; 0,0,1,1]
ex3)
i = 3
j = 4
A = [1,1,1,0,0,0,0,0,0,0,0,0 ; 0,0,0,1,1,1,0,0,0,0,0,0 ; 0,0,0,0,0,0,1,1,1,0,0,0 ; 0,0,0,0,0,0,0,0,0,1,1,1]
Could you MATLAB masters please help me??

Respuesta aceptada

Chunru
Chunru el 9 de Sept. de 2021
i=3;
j=4;
A = kron(eye(j), ones(1,i))
A = 4×12
1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
  1 comentario
연승 김
연승 김 el 9 de Sept. de 2021
wow. it works well!!
you are genius..!!!
Funcicton 'kron' is good^^

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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