Unexpected behavior of mean function
이전 댓글 표시
I did the following:
X = [1;2;3;4;5];
mean X %I know, I forgot the parens - so I expected an error
%Here's what I got
ans = 88 % The ASCII code for 'X'
%Can anyone tell me why I got this answer?
답변 (1개)
"Can anyone tell me why I got this answer?"
You called the command syntax of mean:
As that documentation explains, these two are equivalent:
mean X
mean('X')
Although it can be convenient at the command line, I strongly recommend avoiding the command syntax in code. The command syntax is a momento of MATLAB's venerable age, from the dark-ages when programming languages commonly did such things...
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!