divide a vector into two vectors of unequal length
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
How do I divide a vector into two vectors of unequal length so that the first vector contains 2/3 ,and the other contains1/3
Example
A=[1 2 3 4 5 6]
result
B=[ 1 2 3 4 ]
C=[6 7]
2 Kommentare
Akzeptierte Antwort
Jan
am 1 Okt. 2021
A = [1 2 3 4 5 6];
idx = ceil(numel(A) * 2 / 3);
B = A(1:idx)
C = A(idx + 1:end)
0 Kommentare
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!