Using Julia, I've defined a 9x10 matrix of zeros, and am trying to change a single entry , but I get the error 'setindex!' has no method matching setindex!(::Float64, ::Float64, ::Int64)
My code is:
m = zeros(9,10)
m[1][1] = 1.0
with the error pointing to the second line. typeof(m) is an Array{Float64,2}, which, as far as I can tell is mutable.
What am I doing wrong here?
To index 2-dimensional arrays, just use m[1,1].
The syntax m[1][1] would be valid for a 1-dimensional array of 1-dimensional arrays.
m = zeros(9,10)
m[1,1] = 1.0
m = Array[ [1,2], [3,4,5] ]
m[1][1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With