7
In Octave, kann ichWie führen Sie bedingte Zuweisung in Arrays in Julia durch?
octave:1> A = [1 2; 3 4]
A =
1 2
3 4
octave:2> A(A>1) -= 1
A =
1 1
2 3
aber in Julia, die äquivalente Syntax funktioniert nicht.
julia> A = [1 2; 3 4]
2x2 Array{Int64,2}:
1 2
3 4
julia> A[A>1] -= 1
ERROR: `isless` has no method matching isless(::Int64, ::Array{Int64,2})
in > at operators.jl:33
Wie ordnen Sie bestimmten Array- oder Matrixelementen in Julia bedingte Werte zu?