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!