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
Andrei Bobrov 2017년 7월 12일
Please attach small example of your matrices and expected result
Glazio
Glazio 2017년 7월 13일
@Andrei Bobrov:
The following is a short excerpt from the example matrices.
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
In this test case, these matrices have only four lines, otherwise several thousands.
_ _ _ _
Expected Result: Each row of each matrix represents a run (This means the first line of NSE, RMSE, BIAS and MAD represents a run, the second line of ... and so on). It should now be checked whether the current row (current run) of all matrices is larger than the remaining rows (remaining runs).
In the end, only the pareto-optimal runs should be left. All lines that match the selection criterion (all values in the current row are larger than in the remaining rows) must be removed from the matrices.
Either write the remaining rows into new matrices NSE2014a, ... or into a single matrix with four columns.
As an addition, the index of the remaining rows / runs should be output (based on the original matrices).
Hope it is more understandable, where the problem lies.
Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
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
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);
Glazio
Glazio 2017년 7월 25일
@Andrei Bobrov: It seems to work on smaller matrices and to provide the desired results. Now I will apply your answer to the larger data sets.
Thank you for your help and patience.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by