我有一个包含8列的单元格数组。有时,在最后5列我得到了这个:[](空单元格)。如果它发生,我想完全删除该行。例如:
19970101 18659 183 '19980820' '00018659' 'RUNYON L' '00001534' 'MERRILL'
19970101 18290 183 '19981221' '00018290' 'MANTON S' '00001534' 'MERRILL'
19970101 835 183 [ ] [ ] [ ] [ ] [ ]
19970101 10280 183 '19980819' '00010280' 'BRENNAN S' '00001534' 'MERRILL'
我想得到什么:
19970101 18659 183 '19980820' '00018659' 'RUNYON L' '00001534' 'MERRILL'
19970101 18290 183 '19981221' '00018290' 'MANTON S' '00001534' 'MERRILL'
19970101 10280 183 '19980819' '00010280' 'BRENNAN S' '00001534' 'MERRILL'
非常感谢你的帮助。
答案 0 :(得分:3)
假设input_cellarray
是输入单元格数组,请尝试使用 -
input_cellarray(all(cellfun(@numel,input_cellarray),2),:)
如果您需要,我们必须删除最后5列中只有空单元格[]
的行,那么您需要稍微调整一下代码 -
input_cellarray(any(cellfun(@numel,input_cellarray(:,end-4:end)),2),:)