Calling options for function handles using cellfun

3 visualizaciones (últimos 30 días)
Layla
Layla el 2 de Mayo de 2012
I am confused about how to include options from built-in functions in a cellfun command. When I attempt either of the following commands:
X_member = cellfun('ismember',AllCoordinates, X, 'rows', 'UniformOutput', false)
or
X_member = cellfun(@ismember,AllCoordinates, X, 'rows', 'UniformOutput', false)
I get this error message: Error using cellfun Too many inputs.
I want 'ismember' to operate across rows in the matrices in each cell that I have. AllCoordinates is a 20x1 cell each containing 70000x3 matrices. X is a 20x1 cell containing matrices of different row numbers, but all have 3 columns. Does anybody know how to properly structure that command? Thanks in advance!

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 2 de Mayo de 2012
In order to use ismember with the 'rows' option, you need to build this into the function handle, not cellfun().
Something like:
cellfun(@(c,x)ismember(c,x,'rows'),AllCoordinates,X,'uni',false);
  1 comentario
Layla
Layla el 2 de Mayo de 2012
Thanks! Is there no other way to include function options when using cellfun? I know this method of calling cellfun is the slowest of all three unfortunately (when calling a function like ismember without using any additional options).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Structures 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