Selection data with percentage

1 回表示 (過去 30 日間)
Takim Mustakim
Takim Mustakim 2021 年 9 月 7 日
コメント済み: KSSV 2021 年 9 月 7 日
let's say i have 500 units and i want to move those units to A and B. how to separate those units by percentage 60 to A and 40 to B ??
  2 件のコメント
Sreedhar Arumugam
Sreedhar Arumugam 2021 年 9 月 7 日
編集済み: Sreedhar Arumugam 2021 年 9 月 7 日
Could you please elaborate by what you mean by units? Would it be a matrix or something like a table with multiple groups?
Takim Mustakim
Takim Mustakim 2021 年 9 月 7 日
matrix btw
thank you for respon

サインインしてコメントする。

採用された回答

KSSV
KSSV 2021 年 9 月 7 日
編集済み: KSSV 2021 年 9 月 7 日
X = rand(1,100) ; % say your data or units
n = length(X) ;
% move in the order
A = X(1:60/100*n) ;
B = X(60*n/100+1:end) ;
% move in randomly
idx = randperm(n) ; % randomly arrange the indices
A = X(idx(1:60/100*n)) ;
B = X(idx(60*n/100+1:end)) ;
  3 件のコメント
Takim Mustakim
Takim Mustakim 2021 年 9 月 7 日
"move in randomly" is wrong i think
CMIIW
KSSV
KSSV 2021 年 9 月 7 日
Yes... Indices idx should be used. Edited the code.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by