Is there a function to make a long list of a single value?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
David Haydock
am 24 Mai 2022
Kommentiert: Star Strider
am 24 Mai 2022
I.e. if I want to make a list 400 values long of all 1's, I would use
ones(400,1)
But what if I wanted to make a list of say, 5's?
Is there a function I can use to do this without using a for loop?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 24 Mai 2022
Try this —
Fives = 5*ones(400,1)
.
2 Kommentare
Star Strider
am 24 Mai 2022
Thank you!
I’m certain you would have in a few minutes. (I’ve been doing this for a while.)
Another option —
Fives = 5+zeros(400,1)
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!