how to make a vector of 30 rows 1 column with increasing values of elements
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zishan
am 23 Jun. 2014
Kommentiert: Star Strider
am 26 Jun. 2014
I want to make a matrix of 30 rows 1 column like [1;1;1;1;1;2;2;2;2;2;3;3;3;3;3;4;4;4;4;4;5;5;5;5;5;6;6;6;6;6] please anyone help.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Jun. 2014
Bearbeitet: Star Strider
am 23 Jun. 2014
This works:
V1 = 1:6;
M = repmat(V1', 1, 5)';
V2 = M(:) % Output Vector
7 Kommentare
Star Strider
am 26 Jun. 2014
I do not see a pattern in:
[1;1;1;1;2;2;2;2;2;2;3;3]
so I do not know what to suggest as to how to generate it. If it is random in the length of each value, use the randi function to determine the number of each integer:
Vlen = 10;
V1 = 1:Vlen;
V2 = [];
for k1 = 1:Vlen
V2 = [V2; k1; repmat(k1, randi(9), 1)];
end
Change Vlen to create the approximate length of the vector you want. If you overshoot, simply truncate it to the length you need.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!