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

조회 수: 1 (최근 30일)
Xh Du
Xh Du 2017년 1월 9일
댓글: Xh Du 2017년 1월 9일
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?

채택된 답변

Stephen23
Stephen23 2017년 1월 9일
편집: Stephen23 2017년 1월 9일
cellfun({@(c)c(1,3),respPreStore)
or
cellfun({@(c)c{1,3},respPreStore,'UniformOutput',false)
  댓글 수: 1
Xh Du
Xh Du 2017년 1월 9일
Hi Stephen,
Thanks! I was thinking about using cellfun but I thought there were more straightforward ways like directly manipulating arrays.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by