Borrar filtros
Borrar filtros

calculate the average for each column

1 visualización (últimos 30 días)
marie
marie el 3 de Dic. de 2012
I have a matrix called d=
[99 99 0.100 0.120 0 0.500 0;
0 0 0 0 0.150 0.120 0;
0.110 0.010 0.010 0 0 0.300 0.100;
0 0.250 0 0.050 0.060 0.100 0.110;
0 0.120 0.040 0 0.500 0.750 99];
I want to calculate the average of each column but since I have to take the 99's out. the 99's are located at the first row and last row of the matrix
so far I have
for i=1:5;
weekly_a=mean(d(d(:,i)<99)
since I took the 99 for the first column matlab has as the answ=0.0275 when the correct answer should be 0.022
any sugestion about this?

Respuesta aceptada

Walter Roberson
Walter Roberson el 3 de Dic. de 2012
mean( d( d(:,i)<99, i) )
Notice you had the "i" second dimension missing.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by