You have your own (or some third-party) nanmean.m file .
Notice the error is on line 43 of nanmean. The Mathworks provided nanmean for R2019a is only 22 lines long. Furthermore, the error is shown as being on line 54 of nanvar, but the Mathworks provided nanvar for R2019a has only 42 lines.
I looked back to R2010* and confirmed that the official Mathworks version of nanmean has never had as many as 43 lines.