Quick NAN Question HELP!

A = [1 2 3 1 nan];
If I input
AA~=1
It returns
ans =
0 1 1 0 1
However, If I want to find the replace the un-null elements with 1, returning a matrix like,
ans =
1 1 1 1 0
I tried A~= nan,
However, it returns
ans =
1 1 1 1 1
Any suggestions?

 채택된 답변

Thomas
Thomas 2012년 7월 2일

0 개 추천

use isnan
A = [1 2 3 1 nan];
~(isnan(A))
ans =
1 1 1 1 0

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

태그

질문:

2012년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by