How to compare one row of four matrices with all other rows of these matrices?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Andrei Bobrov
2017년 7월 13일
편집: Andrei Bobrov
2017년 7월 13일
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
Andrei Bobrov
2017년 7월 25일
a = bsxfun(@gt,Matrix,permute(Matrix,[3 2 1]));
t = any(squeeze(all(a,2)),2);
out = Matrix(~t,:);
idx = find(t);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!