Dear all,
I have the following problem with a file, that I attached below. The file is a .txt. When I'm importing the data, I obtain a 43705x1 double file that I renamed x. When I write
>> mean(x)
or
>> sum(x)
the result I obtain is:
ans =
NaN
Why? I checked the presence of NaN in the file, e.g. by
>> x==NaN
but I obtained
>> max(ans)
ans =
logical
0
Does anyone know why there is NaN?
Thank you!

 채택된 답변

Star Strider
Star Strider 2019년 2월 12일

1 개 추천

I cannot reproduce the problem you are seeing.
My code:
T = readtable('01-RHab.txt','ReadVariableNames',0);
x = T.Var1;
mean_x = mean(x)
sum_x = sum(x)
producing:
mean_x =
868.811686380379
sum_x =
37974890

추가 답변 (1개)

Matt J
Matt J 2019년 2월 12일
편집: Matt J 2019년 2월 12일

2 개 추천

To find the location of NaNs, you can do,
find(isnan(x))
Your current method does not work because NaNs are not equal to one another,
>> NaN==NaN
ans =
logical
0

카테고리

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

태그

질문:

2019년 2월 12일

편집:

2019년 2월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by