In Matlab, everything is a matrix, and the default “vector” is a 1×n matrix (though not consistently).
In Julia, we have vectors, which are most similar to an n×1 matrix, but they are really a different animal. For most things, a vector is actually what you want, you’re probably expecting a matrix because that’s what Matlab uses. Try to get used to Julia instead.
This is a UnitRange, which is immutable, it is not an ordinary Vector. Even after transposing, it’s still immutable. If you want to change an element, you must turn it into a Vector first:
Perhaps newcomers can appreciate some explanation of what is going on here. Indeed, by defining A using the colon notation we get a variable that behaves like a vector (or array):
julia> A = 1:1000
1:1000
julia> A[9]
9
The resulting type is actually very memory economical:
julia> sizeof(A)
16
The trick is that this “array” is not really stored as an array.
In contrast, using collect we transform the original variable into a true vector (array):