필터 지우기
필터 지우기

Problem with the mean function

조회 수: 15 (최근 30일)
Mr LE
Mr LE 2015년 1월 31일
댓글: Star Strider 2015년 1월 31일
Hi,
I have a problem with the mean function. I want to have the mean of a matrix A (129x1)
but the function : c= mean (A) doesn't work.
How could I solve this Problem ?
  댓글 수: 2
David Young
David Young 2015년 1월 31일
Do you get an error message, or is the value of c not what you expect?
Mr LE
Mr LE 2015년 1월 31일
The error message is:
Undefined function 'sum' for input arguments of type 'cell'.
Error in mean (line 82) y = sum(x,dim,flag)/size(x,dim);
Error in Devoir1vo (line 16) c= mean (A)

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

채택된 답변

Star Strider
Star Strider 2015년 1월 31일
편집: Star Strider 2015년 1월 31일
In the Command Window, type:
which mean -all
I suspect it will result with the first line being:
mean is a variable.
If it does, you will have to rename whatever your ‘mean’ variable is. (This is the most common problem when built-in functions abruptly fail to work correctly.)
EDIT —
You didn’t mention that ‘A’ was a cell. You can convert it easily to a double array by using the ‘{:}’ notation:
A = {rand(10,1)};
c = mean(A{:});
  댓글 수: 7
Mr LE
Mr LE 2015년 1월 31일
Thanks a lot!
Star Strider
Star Strider 2015년 1월 31일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by