我有一个大型3D CELL ARRAY (x1),我必须删除空行。我怎样才能做到这一点?
我的单元格数组示例(变量的某些部分):
val(:,:,1) =
[20] [] [] [] [] [] [] []
[ 0] [] [] [] [] [] [] []
[ 0] [] [] [] [] [] [] []
[] [] [] [] [] [] [] []
(...)
val(:,:,42) =
[ 34225] [ 215] [ 0] [ 0] [ 0] [ 0] [ 0] [ 0]
[ 85200] [ 545] [ 0] [ 0] [ 0] [ 0] [ 0] [ 0]
[ 65074] [ 190] [ 1000] [ 0] [ 0] [ 0] [ 0] [ 0]
[ 81570] [ 1385] [ 2475] [ 0] [ 0] [ 0] [ 0] [ 0]
[ 67236] [ 530] [ 365] [ 0] [ 0] [ 0] [ 0] [ 0]
[ 61338] [ 0] [ 100] [ 0] [ 0] [ 0] [ 0] [ 0]
[] [] [] [] [] [] [] []
[] [] [] [] [] [] [] []
[] [] [] [] [] [] [] []
在这种情况下,我想从这些变量中排除第 4 行(:,:,1)
、最后三行以及所有其他行。(:,:,42)
我试过了
x1(all(all(cellfun((@isempty,x1),2),:,:) = [];
但它给了我以下错误:
错误:表达式或语句不正确——可能是不平衡的 (、{ 或 [.
PS:我不能使用"=="
,因为它是一个单元阵列。
提前致谢