In Octave I can do
octave:1> A = [1 2; 3 4] A = 1 2 3 4 octave:2> A(A>1) -= 1 A = 1 1 2 3
but in Julia the equivalent syntax does not work.
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
How do you conditionally assign values ββto certain elements of a matrix or matrix in Julia?
octave julia-lang
sffc
source share