Growing eye matrix as per the size of eye

3 visualizzazioni (ultimi 30 giorni)
I have an eye matrix of size eye(3). I need to increase the size of matrix as below so that eye matrix has to repeat 2 times then 3 times. Can anyone help

Risposta accettata

Chunru
Chunru il 2 Giu 2022
a = tril(repmat(eye(3), [3, 3]))
a = 9×9
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1

Più risposte (3)

DGM
DGM il 2 Giu 2022
There are a number of ways, but this is what I'd do:
A = toeplitz([1 0 0 1 0 0 1 0 0],[1 0 0 0 0 0 0 0 0])
A = 9×9
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1

Bruno Luong
Bruno Luong il 2 Giu 2022
Modificato: Bruno Luong il 2 Giu 2022
tril(repmat(eye(3),3))
ans = 9×9
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1

KSSV
KSSV il 2 Giu 2022
REad about diag
I = diag(repelem(1,1,9))+diag(repelem(1,1,6),-3)+diag(repelem(1,1,3),-6)
I = 9×9
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by