Error while computing mean of a row vector

3 vues (au cours des 30 derniers jours)
rihab
rihab le 19 Août 2015
Commenté : Star Strider le 20 Août 2015
I am getting the following error while finding out the mean of a row vector(using the mean function of matlab) containing ten elements:
Subscript indices must either be real positive integers or logicals.
Could any one tell me how to resolve this error?
Thank you!

Réponse acceptée

Star Strider
Star Strider le 19 Août 2015
In the Command Window, type:
which mean -all
If it returns:
mean is a variable.
among its path returns, you are ‘shadowing’ (or ‘overshadowing’) the mean function with a variable you named ‘mean’. The solution is to rename the variable to ‘meanx’ or some such.
  5 commentaires
rihab
rihab le 20 Août 2015
I am getting the same error: Subscript indices must either be real positive integers or logicals.
But now I am calculating it in the traditional way,i.e taking the sum and dividing it by the total number of observations so no longer a problem for me!
Star Strider
Star Strider le 20 Août 2015
I still believe you’re shadowing the mean function somewhere in your code.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by