Problem with mean function
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
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
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
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!