Selection data with percentage
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Takim Mustakim
el 7 de Sept. de 2021
Comentada: KSSV
el 7 de Sept. de 2021
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 comentarios
Sreedhar Arumugam
el 7 de Sept. de 2021
Editada: Sreedhar Arumugam
el 7 de Sept. de 2021
Could you please elaborate by what you mean by units? Would it be a matrix or something like a table with multiple groups?
Respuesta aceptada
KSSV
el 7 de Sept. de 2021
Editada: KSSV
el 7 de Sept. de 2021
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!