Spectral approximation with matrices and discretized operators