4
我需要删除其中具有相同值的矩阵中的任何列。我在MATLAB中使用for-loop来设计它。我想知道是否存在使用矢量化的更好/更快的方法。删除在MATLAB中具有相同值的任何列
mat = [ 0.56 0.2 1 0 45; 0.566 0.2 4 0 45; 0.52 0.2 6 0 45; 0.56 0.2 6 0 41 ];
[row col] = size(mat) ;
bitmat = true(1,col) ;
for i = 2:row, tf = (mat(i-1,:) == mat(i,:)) ; bitmat = bitmat & tf ; end
mat(:,bitmat) = [] ;
谢谢!