reducing matrices under certain conditions

前端 未结 1 1469
深忆病人
深忆病人 2021-01-29 01:19

M is a matrix 4x2000000 composed of several submatrix Ai such that Ai(1:3,j) is the same vector for j = 1,...,size(Ai,2

1条回答
  •  醉梦人生
    2021-01-29 02:05

    One approach -

    [~,~,idx] = unique(M(1:3,:)','rows')  %//'
    valid = ismember(M(4,:),V)
    valid_idx = accumarray(idx(valid),M(4,valid).',[],@(x) ...
                                     numel(unique(x)))>=numel(V) %//'
    out = M(:,ismember(idx,find(valid_idx)))
    

    0 讨论(0)
提交回复
热议问题