Make two groups of data from a given data set

1 visualización (últimos 30 días)
Ali Akber
Ali Akber el 18 de Sept. de 2018
Comentada: jonas el 18 de Sept. de 2018
Hi,
I want to separate some specific data from a given data set. Suppose I have data set r i.e.
r = randi(99,1,500);
I want to make two groups of data based on following conditions
if r<=30 make group 1 (store them in an array)
if r>=35 make group 2 (store them in an array)
Any help in this regard will be highly appreciated.

Respuesta aceptada

jonas
jonas el 18 de Sept. de 2018
Editada: jonas el 18 de Sept. de 2018
Just use logical indexing. Suppose you have a variable A that you want to group based on the values in r.
B{1}=A(r<=35);
B{2}=A(r>35);
Now you have split the array A and stored the sets in a cell array B. Of course, you can replace A by r, if r is the array you want to group.
Note that your signs were inconsistent.
  2 comentarios
Ali Akber
Ali Akber el 18 de Sept. de 2018
Thank you so much. :)
jonas
jonas el 18 de Sept. de 2018
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Acquisition Toolbox Supported Hardware 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!

Translated by