Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

search and retrieve data from cell array

1 visualización (últimos 30 días)
OpenSearch
OpenSearch el 29 de Ag. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have got a cell array containing a column of 1000 (thousand) 2x2 doubles.
Could someone advise on the most efficient way to search for certain numbers in those doubles? And if found (within an error range), to save them in a separate table?
Many thanks in advance!
  1 comentario
Stephen23
Stephen23 el 30 de Ag. de 2018
Editada: Stephen23 el 30 de Ag. de 2018
"Could someone advise on the most efficient way to search for certain numbers in those doubles"
The most efficient way would probably be to use a loop. The easiest way might be to use cellfun. Probably the best way would be to have stored your data in one ND array, then you could write better, simpler, vectorized code:

Respuestas (1)

Matthew
Matthew el 30 de Ag. de 2018
Editada: Matthew el 30 de Ag. de 2018
The easiest way I know of is to use cellfun. For instance if you were looking for numbers that are greater than 2
arraysWithNumbersGreaterThan2_IX = cellfun(@(x) any(any(x > 2)), inputArray)
seperateList = inputArray(arraysWithNumbersGreaterThan2_IX);
If you want to find arrays that have 1, 4, or 7 in them
arraysWithCertainNumbers_IX = cellfun(@(x) any(ismember([1,4,7],x)), inputArray)
seperateList = inputArray(arraysWithCertainNumbers_IX);

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by