필터 지우기
필터 지우기

is the mean function broken in R2014b

조회 수: 2 (최근 30일)
Mike Wilson
Mike Wilson 2018년 5월 23일
댓글: Mike Wilson 2018년 5월 23일
With just about any use of the mean function, i get this error message
Subscript indices must either be real positive integers or
logicals.
I get this error using the example input matrix from docs. I create this matrix.
A = [0 1 1; 2 3 2; 1 3 2; 4 2 2]
Then run this command
M = mean(A)
Above error is generated.
All the other stats functions work as expected. Is this a bug in R2014b?
Is the workaround to write my own mean function?
Thanks,
Mike
  댓글 수: 1
Stephen23
Stephen23 2018년 5월 23일
편집: Stephen23 2018년 5월 23일
"Is this a bug in R2014b?"
Nope. It is because you defined a variable named mean.
"Is the workaround to write my own mean function?"
Nope. The solution is to delete the variable named mean.
This has been discussed many times before:
etc. etc.
Tip for the future: whenever you have a problem with a function one of the first things you should do is check it using which.

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

채택된 답변

the cyclist
the cyclist 2018년 5월 23일
편집: the cyclist 2018년 5월 23일
You probably created a variable named mean, and are accidentally trying to access that variable.
I suggest either doing
clear mean
or just trying again with a freshly started instance of MATLAB.
  댓글 수: 1
Mike Wilson
Mike Wilson 2018년 5월 23일
Thanks to -multiple- folks with the right answer on this. I had created a standin variable named 'mean' for the function i'm writing.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by