divide a vector into two vectors of unequal length

1 次查看(过去 30 天)
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]

采纳的回答

Jan
Jan 2021-10-1
A = [1 2 3 4 5 6];
idx = ceil(numel(A) * 2 / 3);
B = A(1:idx)
B = 1×4
1 2 3 4
C = A(idx + 1:end)
C = 1×2
5 6

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by