# ttest returns NaN even though matrices are finite and does not contain nan?

14 views (last 30 days)
Sugyani Mahapatra on 30 Aug 2017
Edited: Adam Danz on 10 Dec 2019
I have 2 matrices: sample1 - 17*80 and sample2 - 17*80
find(isnan(sample1)==1) and find(isnan(sample2)==1) are empty matrices.
Similarly, find(isfinite(sample1)==0) and find(isfinite(sample2)==0) are empty matrices.
[h,p] = ttest(sample1, sample2) results into a 1*80 vector, each value = NaN.
Why does it happen so??

Katerina Merculy on 13 Apr 2018
I have the same problem and vextors are not the same, they even have different number of rows and I compare ttest(mean(sample1),mean(sample2)) Have you decided this question?
Stephen Cobeldick on 13 Apr 2018

Anthony Peng on 19 Sep 2017
Are the two vectors the same? If they have the same values in them, it will return NaN.

Katerina Merculy on 13 Apr 2018
I have the same problem and vectors are not the same, they even have different number of rows and I compare ttest(mean(sample1),mean(sample2))
ANKUSH JAMTHIKAR on 10 Dec 2019
I have two binary vectors with same elements. I mean, if X and Y are the two binary vectors, then X=Y. Now when I am running ttest(X,Y), it is giving me h=NaN and p=NaN. Does anyone know, how to handel this issue?
I am a bigginner in statistics. So kindly help me to understand this.