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 件)

Stephen23
Stephen23 2020 年 2 月 5 日
編集済み: Stephen23 2020 年 2 月 5 日

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 ExchangeProgramming についてさらに検索

タグ

質問済み:

2020 年 2 月 5 日

編集済み:

2020 年 2 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by