ttest Matlab R2016b does not work properly
古いコメントを表示
Here the code given by mathworks help for the ttest function in R2016b https://www.mathworks.com/help/releases/R2016b/stats/ttest.html?searchHighlight=ttest&s_tid=doc_srchtitle#btrj1_f-1
load examgrade
x = grades(:,1);
y = grades(:,2);
[h,p] = ttest(x,y)
the error I got :
Error using size
Dimension argument must be a positive integer scalar within indexing range.
Error in nanstd (line 59)
tile(dim) = size(x,dim);
Error in ttest (line 132)
sdpop = nanstd(x,[],dim);
The problem is probably at the call of nanstd which the dim=0.
The ttest function is read only from the statistics toolbox.
How to solve this problem?
1 件のコメント
Wouter Maes
2017 年 10 月 11 日
編集済み: Walter Roberson
2017 年 10 月 11 日
I have the exact same problem occurring. I tested several datasets, and ttest always gave this error.
(For instance, I did
Dist=makedist('Normal'); B1=random(Dist,1000,1); [h, p] = ttest(B1);
I always get the error:
Error using size
Dimension argument must be a positive integer scalar within indexing range.
Error in nanmean
Error in nanstd
Error in ttest (line 132)
sdpop = nanstd(x,[],dim);
I'm also runing Matlab R2016b. The statistics and machine learning toolbox is active and working.
Interestingly, I didn't have this error previously (the original script was written one month ago, and the ttest worked properly).
回答 (1 件)
Walter Roberson
2017 年 9 月 14 日
1 投票
The code works fine for me when I test in R2016b.
When I look at the ttest code, the only way that dim could possibly be 0 is if five arguments had been passed into ttest and the 5th one was 0.
Meanwhile, the code for nanstd does not have 59 lines, and has no references to "tile" at all.
I suspect you are getting some different nanstd rather than toolbox/stats/stats/nanstd.m
1 件のコメント
Steven Lord
2017 年 10 月 11 日
To test if Walter's suspicion is correct, use the which function to identify how many copies of the nanstd.m file you have on your path.
which -all nanstd
カテゴリ
ヘルプ センター および File Exchange で Analysis of Variance and Covariance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!