I have a statement in my code where I need to compute the mean of an ND array A along the 1st dimension, which is
M = mean(A,dims=1);
However, sometimes A is just a scalar, in which case an error will be reported, as the “dims” argument is not allowed. What is the correct way of handling this?
1 post - 1 participant