You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: extract_geom.m
    path of file: ./repos/fem_mesh_matlab/fem_mesh_utils
    
    the code of the file until where you have to start completion: function geom = extract_geom(geom_fem, remove_duplicates)
%EXTRACT_GEOM Extract and parse a 2d/3d meshed geometry.
%   geom = EXTRACT_GEOM(geom_fem, remove_
    
function mat_new = substitute_mat(mat_old, v_new, v_old)
%SUBSTITUTE_MAT Substitute values in a matrix.
%   mat_new = SUBSTITUTE_MAT(mat_old, v_new, v_old)
%   mat_old - input matrix (matrix)
%   v_new - value to be substituted (array)
%   v_old - value to be replaced (array)
%   mat_new - output matrix (matrix)

assert(numel(v_new)==numel(v_old), 'invalid substitution')
mat_new = mat_old;
for i=1:numel(v_new)
    mat_new(mat_old==v_old(i)) = v_new(i);
end