ttest Matlab R2016b does not work properly
Mostrar comentarios más antiguos
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 comentario
Wouter Maes
el 11 de Oct. de 2017
Editada: Walter Roberson
el 11 de Oct. de 2017
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).
Respuestas (1)
Walter Roberson
el 14 de Sept. de 2017
1 voto
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 comentario
Steven Lord
el 11 de Oct. de 2017
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
Categorías
Más información sobre Descriptive Statistics and Visualization en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!