function vector = m2v(matrix)
% vector = m2v(matrix). Vector contains all the matrix values, except 0.
[m n] = size(matrix);
q = 0;
for ii = 1:m
  for jj = 1:n
    if matrix(ii,jj) > 0
      q = q + 1;
    end
  end
end
vector(q) = 0;
q = 1;
for ii = 1:m
  for jj = 1:n
    if matrix(ii,jj) > 0
      vector(q) = matrix(ii,jj);
      q = q + 1;
    end
  end
end

