If you have the Signal Processing Toolbox, the hampel function (introduced in R2015b) could do what you want. Check your own R2016b documentation for it, since it could have changed in the last 5 years, and the R2021b documentation I linked to may not strictly apply.)
(I added the Products and Release information in their respective windows. Expand the Products entries if necessary.)
.