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!