Filter löschen
Filter löschen

How can i create this specific matrix??

1 Ansicht (letzte 30 Tage)
연승 김
연승 김 am 9 Sep. 2021
Kommentiert: 연승 김 am 9 Sep. 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??

Akzeptierte Antwort

Chunru
Chunru am 9 Sep. 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 Kommentar
연승 김
연승 김 am 9 Sep. 2021
wow. it works well!!
you are genius..!!!
Funcicton 'kron' is good^^

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by