How to compare one row of four matrices with all other rows of these matrices?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Glazio
am 12 Jul. 2017
Kommentiert: Glazio
am 25 Jul. 2017
In sum, I have four matrices, with a column and thousands of lines. It should now be checked whether the current row of all matrices is larger than the remaining rows.
This means that the first row of each matrix is compared to the remaining rows. Then the second line with the remaining rows etc. ...
If all values in the current row are larger than in the remaining rows, then this row should be removed.
In the end, only those lines should be contained in the four matrices, which at least contain one smaller value.
Furthermore, the indices of the non-rejected rows should be added to the output.
I have tried the following approach, but which does not work, since he does not compare the individual lines over all four matrices.
for n = 1:length(NSE2014);
inrange = bsxfun(@lt,NSE2014(n),NSE2014(n+1)) & bsxfun(@gt,RMSE2014(n),RMSE2014(n+1)) & bsxfun(@gt,BIAS2014(n),BIAS2014(n+1)) & bsxfun(@gt,MAD2014(n),MAD2014(n+1));
% The same has to be done, for 2015 and 2016!
end
Does anyone have an idea how to solve this problem (with Matlab R2012a)?
2 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 13 Jul. 2017
Bearbeitet: Andrei Bobrov
am 13 Jul. 2017
NSE2014 =[
0.2733
0.2930
0.2930
0.2930];
RMSE2014 =[
0.6939
0.6797
0.6797
0.6797];
MAD2014 =[
0.4495
0.4583
0.4583
0.4583];
BIAS2014 =[
0.0826
0.0124
0.0124
0.0124];
M = [NSE2014,RMSE2014,MAD2014,BIAS2014];
out = M(sum(all(M > permute(M,[3 2 1]),2),3) < size(M,1) - 1,:);% R2016b and later
out = M(sum(all(bsxfun(@gt,M,permute(M,[3 2 1])),2),3) < size(M,1) - 1,:);% R2016a and earlier
11 Kommentare
Andrei Bobrov
am 25 Jul. 2017
a = bsxfun(@gt,Matrix,permute(Matrix,[3 2 1]));
t = any(squeeze(all(a,2)),2);
out = Matrix(~t,:);
idx = find(t);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!