필터 지우기
필터 지우기

Take specific elements from each cell of a cell array

조회 수: 2 (최근 30일)
Vasilis Chasiotis
Vasilis Chasiotis 2020년 10월 2일
댓글: Walter Roberson 2020년 10월 2일
Hello! Let A be a 1x10 cell array. Each of the 10 cells of A are nxm matrices.
Also, let an 1x10 vector x, that is, x=[ x1 x2 ... x10 ].
I would like to take the x1 row from the first cell of A, the x2 row from the second cell of A, and so on for all the 10 cells of A.
I have tried cellfun, but I did not achive my goal.
Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2020년 10월 2일
cellfun(@(a, X) a(X,:), A, x, 'uniform', 0)
  댓글 수: 3
Vasilis Chasiotis
Vasilis Chasiotis 2020년 10월 2일
I fixed it!
cellfun(@(a, X) a(X,:), A, num2cell(x), 'uniform', 0)
Walter Roberson
Walter Roberson 2020년 10월 2일
Yes, sorry, that is a good solution there.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by