mean() is giving me an error, when when I use the test code Matlab suggests
3 views (last 30 days)
Show older comments
Hi,
I am unable to reproduce the code given on the help page for the mean() function, https://www.mathworks.com/help/matlab/ref/mean.html
Here is the code I'm trying to run (I have version R2018a installed)
A(:,:,1) = [2 4; -2 1];
A(:,:,2) = [9 13; -5 7];
A(:,:,3) = [4 4; 8 -3];
M1 = mean(A,[1 2])
I keep getting the error:
Error using sum
Dimension argument must be a positive integer scalar within indexing range.
Error in mean (line 116)
y = sum(x, dim, flag) ./ size(x,dim);
I'm not sure why this is happening since this is the code given by the Matlab people, so it should work. Could someone help me with this please? Thanks.
5 Comments
Accepted Answer
Stephan
on 11 Feb 2019
Edited: Stephan
on 11 Feb 2019
Hi,
if you work with R2018a you should use the documentation from R2018a instead of R2018b. Work through the correct documentation and you will have success. Try:
M1 = mean(mean(A,1),2)
Best regards
Stephan
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!