Borrar filtros
Borrar filtros

How to extract cell element from a multi-dimensional cell?

2 visualizaciones (últimos 30 días)
Xh Du
Xh Du el 9 de En. de 2017
Comentada: Xh Du el 9 de En. de 2017
Hi all,
I have a multi-dimensional cell like this:
size(respPreStore)
ans =
1 2 5 2
where each cell element is a 1*3 cell:
respPreStore{1, 1, 1, 1}
ans =
[12x2 double] [2x2 double] [4x2 double]
Now I only want all the third part in the cell, which is the 4*2 double, and store them in another cell. I tried to do this:
respPreStore{:, :, :, :}(1, 3)
MATLAB gives me error:
Expected one output from a curly brace or dot indexing expression, but there were 20 results.
Can anyone tell me how to extract these?

Respuesta aceptada

Stephen23
Stephen23 el 9 de En. de 2017
Editada: Stephen23 el 9 de En. de 2017
cellfun({@(c)c(1,3),respPreStore)
or
cellfun({@(c)c{1,3},respPreStore,'UniformOutput',false)
  1 comentario
Xh Du
Xh Du el 9 de En. de 2017
Hi Stephen,
Thanks! I was thinking about using cellfun but I thought there were more straightforward ways like directly manipulating arrays.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by