'ttest' function not working in Matlab

1

When I am using this statement in Matlab in my computer then its giving error as follow:

 [h,p,ci]=ttest(randn(100,1),0.1)

Error:

??? Error using ==> nanmean
Too many input arguments.

Error in ==> ttest at 104
xmean = nanmean(x,dim);

However if I use the same statement in Matlab in another computer, then its working fine and giving results. Do you know what could be the problem? I am posting this question here suspecting it to be some software problem with Matlab. Correct me if I am wrong.

user42307

Posted 2010-09-28T21:26:54.147

Reputation:

Answers

1

If the same code works on one and not on the other, then my guess is the version of matlab your using on one is pickier than on another. Have you checked that they are the same version of matlab on both machines? My guess is they are different.

Regardless, some thing to try:

It looks to me as if one matlab version is treating the output as randn as a series of arguments passed to ttest, not as a vector containing your random sample.

Also, just to help debug, I would use:

x=randn(100,1)
[h,p,ci]=ttest(x,0.1)

Have you tried x=randn([100,1])? Although I would not expect this to matter...

Is it possible that sometimes 0.1 doesn't make sense as a mean for the set? Looking at x might help. My guess is this will work on both, assuming you want the mean to be = 0.1:

% Generate values from a normal distribution with mean 0.1 
% and standard deviation 0.5
x=0.1 + 0.5*randn(100,1)
[h,p,ci]=ttest(x)

DaveParillo

Posted 2010-09-28T21:26:54.147

Reputation: 13 402

1Problem solved. It was actually a path related problem. The nanmean.m file was is mGstat toolbox instead of being in STATS toolbox, where ttest.m is placed. Thank you! – None – 2010-09-28T22:01:10.740