Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

How to correctly handle one-element array vs scalar

$
0
0

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

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles