How do you create a new vector using every other number from your original vector. Including the first number of the original vector.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
How do you create a new vector using every other number from your original vector. Including the first number of the original vector.
0 Kommentare
Antworten (1)
per isakson
am 29 Jan. 2018
Bearbeitet: per isakson
am 29 Jan. 2018
An example
>> vec = randi(3,1,18) % test data
vec =
Columns 1 through 14
3 3 1 3 2 1 1 2 3 3 1 3 3 2
Columns 15 through 18
3 1 2 3
>> vec( 1 : 2 : end ) % every other value
ans =
3 1 2 1 3 1 3 3 2
a better example
>> vec = 1:18;
>> vec( 1 : 2 : end )
ans =
1 3 5 7 9 11 13 15 17
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Types 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!