Effacer les filtres
Effacer les filtres

Problem with the mean function

15 vues (au cours des 30 derniers jours)
Mr LE
Mr LE le 31 Jan 2015
Commenté : Star Strider le 31 Jan 2015
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 commentaires
David Young
David Young le 31 Jan 2015
Do you get an error message, or is the value of c not what you expect?
Mr LE
Mr LE le 31 Jan 2015
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)

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 31 Jan 2015
Modifié(e) : Star Strider le 31 Jan 2015
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 commentaires
Mr LE
Mr LE le 31 Jan 2015
Thanks a lot!
Star Strider
Star Strider le 31 Jan 2015
My pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by