finding difference in matrix

2 visualizaciones (últimos 30 días)
Pat
Pat el 26 de Nov. de 2012
A=[ 8.9724 14.5105 7.4390 8.3401 11.3161 5.5572 10.0719
1.8233 2.6026 26.3023 14.0506 29.8088 25.8791 23.3959
4.3403 24.1108 28.4506 13.5936 6.8717 0.8964 17.2434 ];
I need to take 1st column and match with other column if the values are within a range of +/-10 from the column taken,for those mean must be taken
for example taking 1st col it doesnot have a difference of +/-10 with any other column,2nd,3rd dont have
4th and 7th have a difference of +/-10,i have to fine mean in row wise
8.3401 10.0719
14.0506 23.3959
13.5936 17.2434
mean is
9.206
18.723
15.4185
same as 5th andd th has the difference,and have to find mean
finally i need output as meanvalue and the column for which mean is not taken
so 1st,2nd,3rdcolumns,mean value1,meanvalue2 must be displayed
please help
  4 comentarios
Walter Roberson
Walter Roberson el 27 de Nov. de 2012
Do you mean 10, or 10% ? All of the values in the first column are within +/- 10 of each other, but not all of them are within 10% of each other. On the other hand you specifically identify column 4 and column 7, but 10.0719 is not within 10% of 8.3401 and 8.3401 is not within 10% of 10.0719. Your criteria is not at all clear.
Pat
Pat el 27 de Nov. de 2012
walter not 10% it is a diference of +/-10,comparing 4th column and 7th column
8.3401 10.0719
14.0506 23.3959
13.5936 17.2434
they differ by a value of +/-10
5th and 6th column also differ at a difference of +/- 10;
for example in 6th and 7th cannot be combined because the 3rd row value
is greater than 10

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 26 de Nov. de 2012
Once you have the differences, the rest should be easy:
A= bsxfun(@minus, A, A(:,1));
  3 comentarios
Matt J
Matt J el 26 de Nov. de 2012
Editada: Matt J el 26 de Nov. de 2012
You said that the first step in your process is to see which columns are within +/-10 of the first column. subtracting the 1st column from the others would be a step in doing so. Taking it a step further, it might be useful for you to do
all( abs(bsxfun(@minus, A, A(:,1)))<=10,1) ;
Pat
Pat el 27 de Nov. de 2012
But matt the value i get is
ans =
1 0 0 0 0 0 0
what does it mean

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB 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