Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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)
share|improve this answer
1  
Problem 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! –  Pupil Sep 28 '10 at 22:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.