Computation of scattering matrices and resonances for waveguides