finding difference in matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 27 Nov. 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.
Antworten (1)
Matt J
am 26 Nov. 2012
Once you have the differences, the rest should be easy:
A= bsxfun(@minus, A, A(:,1));
3 Kommentare
Matt J
am 26 Nov. 2012
Bearbeitet: Matt J
am 26 Nov. 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) ;
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!