Delete some columns from a cell array depending on an array SP

조회 수: 1 (최근 30일)
luca
luca 2019년 10월 15일
댓글: luca 2019년 10월 15일
Given the cell array
V={{[1,1,1,1;25,45,70,90],[2,2,2,2;78,112,146,180],[3,3,3,3;93,127,161,195],[4,4;70,100],[],[6;85],[],[],[9,9;85,110]},{[],[2,2,2,2;73,107,141,175],[3,3,3,3;83,117,151,185],[4,4,4,4;65,85,105,125],[],[6;85],[],[],[9,9,9;80,105,130]}};
and the array
SP= [1 2 3 4 6 9];
I want to remove from the cells V the column that are not in SP.so column 5 7 8. obtaining
V={{[1,1,1,1;25,45,70,90],[2,2,2,2;78,112,146,180],[3,3,3,3;93,127,161,195],[4,4;70,100],[6;85],[9,9;85,110]},{[],[2,2,2,2;73,107,141,175],[3,3,3,3;83,117,151,185],[4,4,4,4;65,85,105,125],[6;85],[9,9,9;80,105,130]}};
May someone help me?
  댓글 수: 3
Guillaume
Guillaume 2019년 10월 15일
Yes.
The [] around SP are pointless though.

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

답변 (0개)

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by