length of arrey in cell and remove 0

2 次查看(过去 30 天)
A={[113],[112],[42],[29],[113],[69],[86],[0],[0]};
B={[18],[14],[5],[39],[27],[11],[9],[0],[0]};
C=cellfun(@(m,u) length(m)+length(u),A, B, 'uni',0);
as 2 last element in both A and B is 0
I want to have this result
C={[2],[2],[2],[2],[2],[2],[2],[0],[0]}

采纳的回答

madhan ravi
madhan ravi 2019-4-21
编辑:madhan ravi 2019-4-21
A(cell2mat(A)==0)={[]}; % assuming each cell is scalar
B(cell2mat(B)==0)={[]};
C=cellfun(@(m,u) numel(m)+numel(u),A, B, 'un',0)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 3-D Scene Control 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by