How to create an array
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
JRC
am 19 Jul. 2017
Kommentiert: Star Strider
am 19 Jul. 2017
How to create an array
A = [0 0 0 0; 1 1 1 1; 2 2 2 2; 3 3 3 3; 4 4 4 4]
using the command "for" or other?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 19 Jul. 2017
Use the repmat function:
A = repmat(0:4, 4, 1)';
A =
0 0 0 0
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
2 Kommentare
Star Strider
am 19 Jul. 2017
As always, my pleasure!
Another option for your particular problem is to use element-wise vector multiplication:
A = [0:4]'.*ones(1,4);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations 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!