Populate array in Julia with Measurements.jl variables

Viewed 35

Newbie to Julia (coming from Matlab). I need to populate arrays with X ± Y variables, using Measurements.jl. Suggestions please? For example:

using Measurements
X = (40,) of values
Y = (40,) of uncertainties
Z = zeros(40)
for i in 1:40
Z[i] = X[i] ± Y[i]
end

The above loop doesn't work, nor does:

for i in 1:40
Z[i] = measurement(X[i],Y[i])
end

Nor does:

Z = X ± Y

or:

Z = measurement(X,Y)

but:

i = 1
Z = X[i] ± Y[i]
Z = measurement(X[i],Y[i])

both work, though of course returning only one Z

1 Answers

Just solved my own question. Syntax is:

Z = X .± Y
Related