calculating average without using the mean function

16 visualizaciones (últimos 30 días)
NNADOZIE OPARA
NNADOZIE OPARA el 2 de Feb. de 2019
Editada: Stephen23 el 2 de Feb. de 2019
I am trying to calculating the average of a number set.
This is what i have done so far but it is not running smoothly
function [A] = average(X);
%this program calculates the average of a given number set
%enter the numbers either in a column or in a row; i.e use either a column
%vector or a row vector
[A] = Sum(X)/length(X)
%this will give the sum of the number set

Respuestas (1)

Image Analyst
Image Analyst el 2 de Feb. de 2019
Try using sum() instead of Sum(). MATLAB is case sensitive.
  1 comentario
NNADOZIE OPARA
NNADOZIE OPARA el 2 de Feb. de 2019
thanks...
MATLAB is indeed case sensitive.
i have tried it and the program ran

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by