필터 지우기
필터 지우기

question on cell array

조회 수: 2 (최근 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