hi guys
I cannot understand what is happening when we are coding this;
K=0:0.01:1;
[rowK,colK]= size(K);
aux=zeros(colK,colK)+NaN;
In the auxiliary matrix which is being defined what role does NaN plays?
Thanks

 채택된 답변

Ahmet Cecen
Ahmet Cecen 2016년 12월 28일
편집: Ahmet Cecen 2016년 12월 28일

1 개 추천

Looks like the code intended to initialize a matrix filled with NaNs and does this by adding NaN to a zero matrix. Any number + NaN is NaN.
You could achieve the same effect with:
aux = NaN(colK);
One common reason you would use NaN instead of 0 is to differentiate when you actually have a value of 0 (say 0 Celsius) versus you have no idea what that value is.

추가 답변 (0개)

카테고리

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

질문:

2016년 12월 28일

편집:

2016년 12월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by