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 次查看(过去 30 天)
显示 更早的评论
For example :
A = [1 2 3 NaN 3 5]; if isnan(A) ~= 0 %... end
0 个评论
采纳的回答
KSSV
2017-10-12
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
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!