Remove empty cells (of a m*n cell)

조회 수: 1 (최근 30일)
Louise
Louise 2021년 2월 17일
댓글: Louise 2021년 3월 17일
Hello,
You could find attached a cell. My aim is to remove all empty cells in order to have a 10x14 cell.
I've try the following function :
Cell=(cellfun('isempty', Cell));
Cell(idx) = [];
But I got a 1x140 cell (instead of 10x14)
Thanks in advance for your help,
Marie

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 17일
load Cell
Step_40C_2
NE = ~cellfun(@isempty,Step_40C_2);
temp = arrayfun(@(C) Step_40C_2(NE(:,C),C), 1:size(Step_40C_2,2), 'uniform', 0);
Cell = horzcat(temp{:})
Or
load Cell
Step_40C_2
NE = ~cellfun(@isempty,Step_40C_2);
Cell = reshape(Step_40C_2(NE), [], size(Step_40C_2,2))
  댓글 수: 1
Louise
Louise 2021년 3월 17일
Within a structure, is it possible to remove emtpy cell ?
For example in the capture, I would like that rows 13 to 26 move to rows 1 to 12...

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by