How to remove zeros from non linear array
显示 更早的评论
How to remove more zeros from each row of non linear array. we have [1269*100] array structure. my output is like [1 2 3 0 0; 1 4 0 0; 1 2 3 0 0]. I need the output of each row like [1 2 3; 1 4; 1 2 3].
3 个评论
Walter Roberson
2018-3-14
Are only trailing zeros to be removed, or all zeros? Is it certain that there will be the same number of zeros to be removed for each row?
Walter Roberson
2018-3-14
How does this differ from your existing question https://www.mathworks.com/matlabcentral/answers/388160-i-want-to-remove-zeroes-from-an-array-the-array-more-zero-per-row-for-example-a-200-03-303 ?
Sarumathi C
2018-3-14
回答(1 个)
Walter Roberson
2018-3-14
cell2mat( cellfun( @(V) V(V~=0), num2cell(YourArray, 2), 'uniform', 0))
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!