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 个评论
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