关于MATLAB mean函数的问题!A=[1 3 4 5; 2 3 4 6;1 3 1 5]对矩阵A求平均,mean(A):如果是求平均的话,答案应该是:1.3333 3.0000 3.0000 5.3333为什么我这显示的答案是:4 9 9 16请问有人碰到这种情况没有?>> A=[1 3
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/29 00:27:26
![关于MATLAB mean函数的问题!A=[1 3 4 5; 2 3 4 6;1 3 1 5]对矩阵A求平均,mean(A):如果是求平均的话,答案应该是:1.3333 3.0000 3.0000 5.3333为什么我这显示的答案是:4 9 9 16请问有人碰到这种情况没有?>> A=[1 3](/uploads/image/z/7827897-57-7.jpg?t=%E5%85%B3%E4%BA%8EMATLAB+mean%E5%87%BD%E6%95%B0%E7%9A%84%E9%97%AE%E9%A2%98%21A%3D%5B1+3+4+5%3B+2+3+4+6%3B1+3+1+5%5D%E5%AF%B9%E7%9F%A9%E9%98%B5A%E6%B1%82%E5%B9%B3%E5%9D%87%2Cmean%28A%29%3A%E5%A6%82%E6%9E%9C%E6%98%AF%E6%B1%82%E5%B9%B3%E5%9D%87%E7%9A%84%E8%AF%9D%2C%E7%AD%94%E6%A1%88%E5%BA%94%E8%AF%A5%E6%98%AF%EF%BC%9A1.3333+3.0000+3.0000+5.3333%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E8%BF%99%E6%98%BE%E7%A4%BA%E7%9A%84%E7%AD%94%E6%A1%88%E6%98%AF%EF%BC%9A4+9+9+16%E8%AF%B7%E9%97%AE%E6%9C%89%E4%BA%BA%E7%A2%B0%E5%88%B0%E8%BF%99%E7%A7%8D%E6%83%85%E5%86%B5%E6%B2%A1%E6%9C%89%3F%3E%3E+A%3D%5B1+3)
关于MATLAB mean函数的问题!A=[1 3 4 5; 2 3 4 6;1 3 1 5]对矩阵A求平均,mean(A):如果是求平均的话,答案应该是:1.3333 3.0000 3.0000 5.3333为什么我这显示的答案是:4 9 9 16请问有人碰到这种情况没有?>> A=[1 3
关于MATLAB mean函数的问题!
A=[1 3 4 5; 2 3 4 6;1 3 1 5]
对矩阵A求平均,mean(A):
如果是求平均的话,答案应该是:1.3333 3.0000 3.0000 5.3333
为什么我这显示的答案是:4 9 9 16
请问有人碰到这种情况没有?
>> A=[1 3 4 5; 2 3 4 6;1 3 1 5];
>> B=mean(A)
B =
4 9 9 16
>> C=mean(A,1)
Error using ==> mean
Too many input arguments
我刚把这位仁兄的代码替换了我机子上的mean.m.结果还是如上,疯了!
关于MATLAB mean函数的问题!A=[1 3 4 5; 2 3 4 6;1 3 1 5]对矩阵A求平均,mean(A):如果是求平均的话,答案应该是:1.3333 3.0000 3.0000 5.3333为什么我这显示的答案是:4 9 9 16请问有人碰到这种情况没有?>> A=[1 3
在命令行输入which mean
把结果发上来
无语,你先把which mean的结果发上来,我怀疑你自己写过一个叫mean的函数
>> A=[1 3 4 5; 2 3 4 6;1 3 1 5];
>> mean(A,1)
ans =
1.3333 3.0000 3.0000 5.3333
>> mean(A,2)
ans =
3.2500
3.7500
2.5000
>>
mean(A,1)表示对列取平均,mean(A,2)表示对行取平均,mean(A)则默认为mean(A,1)
高度怀疑你的函数mean被修改了,是不是别人用过你的电脑,这样:在磁盘:\matlb\toolbox\matlab\datafun下可以找到mean,把以下原代码贴到里面去:
function y = mean(x,dim)
%MEAN Average or mean value.
% For vectors, MEAN(X) is the mean value o...
全部展开
高度怀疑你的函数mean被修改了,是不是别人用过你的电脑,这样:在磁盘:\matlb\toolbox\matlab\datafun下可以找到mean,把以下原代码贴到里面去:
function y = mean(x,dim)
%MEAN Average or mean value.
% For vectors, MEAN(X) is the mean value of the elements in X. For
% matrices, MEAN(X) is a row vector containing the mean value of
% each column. For N-D arrays, MEAN(X) is the mean value of the
% elements along the first non-singleton dimension of X.
%
% MEAN(X,DIM) takes the mean along the dimension DIM of X.
%
% Example: If X = [0 1 2
% 3 4 5]
%
% then mean(X,1) is [1.5 2.5 3.5] and mean(X,2) is [1
% 4]
%
% Class support for input X:
% float: double, single
%
% See also MEDIAN, STD, MIN, MAX, VAR, COV, MODE.
% Copyright 1984-2005 The MathWorks, Inc.
% $Revision: 5.17.4.3 $ $Date: 2005/05/31 16:30:46 $
if nargin==1,
% Determine which dimension SUM will use
dim = min(find(size(x)~=1));
if isempty(dim), dim = 1; end
y = sum(x)/size(x,dim);
else
y = sum(x,dim)/size(x,dim);
end
收起
表示的是列平均而不是行平均 用mean(A,2)