julia select all but one element in array/matrix

You should use the Not function, which constructs an inverted index:

A = rand(3,3)
A[Not(2), :]
A[:, Not(2)]

You can find the Not function in the InvertedIndices.jl package.


Here is one option:

A = rand(3,3)
B = A[1:end .!= 2,:]

1:end gets a complete list of row indices (you could also use 1:size(A,1)) and then .!= (note the . indicating element-wise comparison) selects the indices not equal to 2.

If you wanted to select columns in this way you would use:

C = A[:, 1:end .!= 2]

Note that the end keyword automatically will equal the last index value of the row, column, or other dimension you are referencing.

Note: answer updated to reflect improvements (using end instead of size()) suggested by @Matt B in comments.