I'm trying to check for a NaN value in an array in if condition expression but the control is not entering inside if condition.

2 Ansichten (letzte 30 Tage)
For example :
A = [1 2 3 NaN 3 5]; if isnan(A) ~= 0 %... end

Akzeptierte Antwort

KSSV
KSSV am 12 Okt. 2017
A = [1 2 3 NaN 3 5];
idx = isnan(A) ; % all NaN indices at once
for i = 1:length(A)
if isnan(A(i))
fprintf('%d index value is NaN\n',i)
end
end

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by