trouble with using isnan function

조회 수: 6 (최근 30일)
Richard Silberstein
Richard Silberstein 2019년 11월 5일
답변: Richard Silberstein 2019년 11월 5일
Hi,
I have 51 complex arrays temp1(2X390X51). Now I know that all arrays except temp1(:,:,25) comprises valid numerical values.
And all the values in temp1(:,:,25) are described as NaN by matlab. When I use the following in the Command Window: isnan(temp1(2,1,25)) I get the correct Logical 1 ie true) which is correct.
However, when I put the same line: isnan(temp1(2,1,25)) in a loop, the expression yields Logical 0. (ie false, which it is not)
Can anyone tell me what I'm doing wrong?
Thanks
Richard
  댓글 수: 2
the cyclist
the cyclist 2019년 11월 5일
It would be much easier to diagnose the problem if you upload code and/or variables (in a *.mat file), using the paper clip icon.
James Tursa
James Tursa 2019년 11월 5일
편집: James Tursa 2019년 11월 5일
Likely the temp1 you are using in a loop differs from the temp1 you are using at the command line. I.e., something in your code is making them different before you do the compare.

댓글을 달려면 로그인하십시오.

답변 (1개)

Richard Silberstein
Richard Silberstein 2019년 11월 5일
Thank you James and 'the cyclist',
I did appreciate your prompt input and suggestions.
I did find the source of my confusion, I mistook a processed array for an input array.
The processed array comprised NaN while the input array that caused the problem comprised complex zeros.
Thanks again,
Richard

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by