필터 지우기
필터 지우기

Problem with mean function

조회 수: 3 (최근 30일)
Nina Schuback
Nina Schuback 2017년 7월 20일
댓글: carsten 2018년 7월 18일
If I try to calculate a simple mean say A=[1,2,3]; M=mean(A) I get an error message saying 'Undefined function 'mean' for input arguments of type 'double' I checked if I have overwritten mean with which mean -all and get the following answer:
C:\Program Files\MATLAB\R2016A\Research\toolbox\matlab\timefun\@duration\mean.m % duration method
C:\Program Files\MATLAB\R2016A\Research\toolbox\matlab\timefun\@datetime\mean.m % datetime method
C:\Program Files\MATLAB\R2016A\Research\toolbox\distcomp\parallel\@codistributed\mean.m % codistributed method
C:\Program Files\MATLAB\R2016A\Research\toolbox\distcomp\gpu\@gpuArray\mean.m % gpuArray method
C:\Program Files\MATLAB\R2016A\Research\toolbox\stats\stats\@ProbDistUnivParam\mean.m % ProbDistUnivParam method
C:\Program Files\MATLAB\R2016A\Research\toolbox\matlab\timeseries\@timeseries\mean.m % timeseries method

채택된 답변

John D'Errico
John D'Errico 2017년 7월 20일
What you are missing is this version of mean:
/Applications/MATLAB_R2017a.app/toolbox/matlab/datafun/mean.m
At least that is the search path to it on my mac. The path to that function on your system will be different, but you apparently lack a function called mean in the datafun directory.
So, possibly you have deleted mean from that directory. More likely, do you have the datafun directory on your path at all? I'll conjecture that you may have accidentally removed it from your search path.
So check your search path. Just type path at the command line.
path
Your search path should list a directory datafun, that should be here:
C:\Program Files\MATLAB\R2016A\Research\toolbox\matlab\datafun
  댓글 수: 2
Nina Schuback
Nina Schuback 2017년 7월 21일
Thanks!
carsten
carsten 2018년 7월 18일
Hey there, I am facing the same problem as Nina described above:
>> A = [0 1 1; 2 3 2; 1 3 2; 4 2 2];
>> mean(A);
Undefined function 'mean' for input arguments of type 'double'.
Apparently the mean function of datafun can not be accessed
>> which mean -all
C:\Program Files\matlab_v86_r15b_x64\toolbox\matlab\timefun\@duration\mean.m % duration method
C:\Program Files\matlab_v86_r15b_x64\toolbox\matlab\timefun\@datetime\mean.m % datetime method
C:\Program Files\matlab_v86_r15b_x64\toolbox\distcomp\parallel\@codistributed\mean.m % codistributed method
C:\Program Files\matlab_v86_r15b_x64\toolbox\distcomp\gpu\@gpuArray\mean.m % gpuArray method
C:\Program Files\matlab_v86_r15b_x64\toolbox\stats\stats\@ProbDistUnivParam\mean.m % ProbDistUnivParam method
C:\Program Files\matlab_v86_r15b_x64\toolbox\matlab\timeseries\@timeseries\mean.m % timeseries method
even though the datafun directory is listed in the path.
>> path
MATLABPATH
U:\MATLAB
...
C:\Program Files\matlab_v86_r15b_x64\toolbox\matlab\codetools
C:\Program Files\matlab_v86_r15b_x64\toolbox\matlab\datafun
C:\Program Files\matlab_v86_r15b_x64\toolbox\matlab\datamanager
...
Things I have tried so far:
(1) Deinstalltion and new installation of MATLAB but the problem still exists.
(2) When I navigate into the the datafun directory and run the same commands as above the mean function runs smoothly, so the function itself seems to be fine.
(3) Checking the configuration on a different computer:
>> which mean -all
C:\Program Files\MATLAB_v86_r15b_x64\toolbox\matlab\datafun\mean.m
C:\Program Files\MATLAB_v86_r15b_x64\toolbox\matlab\timefun\@duration\mean.m % duration method
C:\Program Files\MATLAB_v86_r15b_x64\toolbox\matlab\timefun\@datetime\mean.m % datetime method
C:\Program Files\MATLAB_v86_r15b_x64\toolbox\distcomp\parallel\@codistributed\mean.m % codistributed method
C:\Program Files\MATLAB_v86_r15b_x64\toolbox\distcomp\gpu\@gpuArray\mean.m % gpuArray method
C:\Program Files\MATLAB_v86_r15b_x64\toolbox\stats\stats\@ProbDistUnivParam\mean.m % ProbDistUnivParam method
C:\Program Files\MATLAB_v86_r15b_x64\toolbox\matlab\timeseries\@timeseries\mean.m % timeseries method
So the first line with the datafun entry is missing in my configuration.
How can I fix this problem?
@Nina: Could you please describe how you fixed it?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

RobF
RobF 2018년 7월 18일
Two commands that might always help when having path issues are the following:
>> restoredefaultpath
and
>> rehash
respectively
>> rehash path
>> rehash toolbox
>> rehash toolboxcache
Just enter them at your Matlab command prompt and check, if the functions are now available. More information:
>> doc restoredefaultpath
>> doc rehash
  댓글 수: 1
carsten
carsten 2018년 7월 18일
The command
>> rehash toolbox
worked for me. Many thanks!!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by