does a cell vector contains only NaN?

조회 수: 3 (최근 30일)
Sabbas
Sabbas 2012년 8월 10일
Dear all,
I have
A={
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]
[NaN]}
and I want to find a command that will tell me if A contains only NaN.
I tried
all(isnan(cell2mat(A))), 2) == NaN
but it does not work
cheers

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 8월 10일
cisnan = @(C)all(cellfun(@(x)all(isnan(x(:))),C));
cisnan(your_cell)

추가 답변 (1개)

Wayne King
Wayne King 2012년 8월 10일
편집: Wayne King 2012년 8월 10일
There are many ways:
nanarray = cell2mat(cellfun(@isnan,A,'uni',0));
length(nanarray>0)
% the above gives you the answer -- for example
if (length(nanarray>0) > 0)
disp('The cell array contains NaNs')
end

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by