how to find an empty row in a table
조회 수: 102 (최근 30일)
이전 댓글 표시
Hello, I'm trying to get rid of a certain row in a single column table that only has a []. for example if I have a table.
column 1
row1 | 'hey' |
row2 | 'hey' |
row3 | [ ] |
how can I get it to be
column 1
row1 | 'hey' |
row2 | 'hey' |
I have a code that works but for larger tables it's extreemely slow.
yee = "original table";
yee1=table;
for n=1:numel(yee)
if isa(yee{n},'char')
bus=yee(n);
yee1 = [yee1 ; bus];
end
end
I feel like there's a lot more efficient ways to do this. Thanks for any help!
댓글 수: 0
채택된 답변
Matt J
2019년 6월 21일
편집: Matt J
2019년 6월 21일
loc=cellfun('isempty', yourTable{:,'column1'} );
yourTable(loc,:)=[]
댓글 수: 3
Gabor
2021년 3월 4일
For me it works if I convert the table to cell and I use the column number in the script:
yourTable2=table2cell(yourTable);
loc=cellfun('isempty', yourTable2{:,1} );
I hope it helps someone.
추가 답변 (1개)
Guillaume
2019년 6월 21일
Even simpler, and probably faster, use the table tools (rather than cell array tools):
yourtable = rmmissing(yourtable)
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!