Ajouter 'octave/selcol.m'

This commit is contained in:
Rémi BUSSIERE 2023-02-19 22:48:38 +01:00
parent 2715650503
commit d86c595703
1 changed files with 24 additions and 0 deletions

24
octave/selcol.m Normal file
View File

@ -0,0 +1,24 @@
function newMatrix = selcol(oldMatrix, maskVector);
% newMatrix = selcol(oldMatrix, maskVector);
% Selects the columns of the matrix that marked by one in the given vector.
% The maskVector is a column vector.
% 15.3.1998
if size(maskVector, 1) ~= size(oldMatrix, 2),
error ('The mask vector and matrix are of uncompatible size.');
end
numTaken = 0;
for i = 1 : size (maskVector, 1),
if maskVector(i, 1) == 1,
takingMask(1, numTaken + 1) = i;
numTaken = numTaken + 1;
end
end
newMatrix = oldMatrix(:, takingMask);
endfunction