MATLAB: Do I get “Error using sum” message when following the examples in “mean” function documentation

MATLAB

I am just following the example in the "mean" function documentation, but get the following errors instead:
>> A(:,:,1) = [2 4; -2 1];
>> A(:,:,2) = [9 13; -5 7];
>> A(:,:,3) = [4 4; 8 -3];
>>
>> M1 = mean(A, [1 2])
Error using sum
Dimension argument must be a positive integer scalar within indexing range.
Error in mean (line 117)
y = sum(x, dim, flag)/size(x,dim);
>> M1 = mean(A,'all')
Error using sum
Invalid option. Option must be 'double', 'native', 'default', 'omitnan' or 'includenan'.
Error in mean (line 117)
y = sum(x, dim, flag)/size(x,dim);

Best Answer

These syntax are new features that are not available prior to MATLAB R2018b:
Verify that you have MATLAB R2018b to run the examples in the documentation page.