julia> fill(NaN,(3,4))
3×4 Matrix{Float64}:
NaN NaN NaN NaN
NaN NaN NaN NaN
NaN NaN NaN NaN
You are lucky, that will be possible in V1.7 already:
julia> A = rand(3,4); B = rand(3,4);
julia> inds = A .> 0.5 .&& B .> 0.5
3×4 BitMatrix:
0 0 0 0
0 1 1 0
0 0 1 1
Currently you can already do this:
julia> A = rand(3,4); B = rand(3,4);
julia> (A .> 0.5) .& (B .> 0.5)
3×4 BitMatrix:
0 0 0 0
0 1 1 1
0 0 1 0
(and I don’t see any immediate harm in that, with the parenthesis, maybe someone can correct me)
If you are just pushing to A
for the first time, just do A = b
.
The difference between vectors and matrices is a feature, actually, and the old julia and matlab users have discussed many times the advantages of that here.
that can be done:
julia> f(x) = 2
f (generic function with 1 method)
julia> f(1)
2
(but you need to learn the syntax first).
I’m not sure what you want to do here, but isn’t this just this? (edit: or more likely, one of the options here: Sort matrix based on the elements of a specific column - #5 by nicolas - a function that sorts the matrix as a function of one row may exist, I’m not sure)
julia> A = rand(3,4);
julia> sort(A, dims=2)
3×4 Matrix{Float64}:
0.0518517 0.055554 0.248347 0.992392
0.168324 0.318615 0.857768 0.864286
0.0809794 0.541194 0.724404 0.911751