question on cell array

1 次查看(过去 30 天)
jana
jana 2013-9-10
I have the following cell arrays:
K{1} = [0,1,2,4]
K{2} = [3,6,7]
K{3} = [0,3,7]
I want to check if my cell array has a zero and get rid of that zero. My cell array is sorted so if there is a zero, it will be in the first indice. please help.

采纳的回答

the cyclist
the cyclist 2013-9-10
K = cellfun(@(x)x(x~=0),K,'UniformOutput',false)

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-9-10
for k=1:numel(K)
if K{k}(1)==0
K{k}=K{k}(2:end);
end
end

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by