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?

Réponses (1)

Stephen23
Stephen23 le 5 Fév 2020
Modifié(e) : Stephen23 le 5 Fév 2020
"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...

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by