In matlab, deleting the 2nd row of matrix A is
A(2,:) = [];
How to delete a row of matrix in julia? I tried to use A(2,:
I don't know the first thing about Julia, but I think it uses square brackets ([]
) for indexing, so you should try the following:
A[2, :] = []
I don't have a Julia interpreter at hand to test that, but if that also fails, surely the following should work:
A = A[[1, 3:end], :]
which simply uses the reverse strategy of selecting the rows that you want to keep.
You can't delete a row from a matrix – the fact that Matlab has easy syntax for this is a bit of a trap because the actual way you have to delete a row is to create a copy without the row so we decided to make that explicit and thereby have more transparent performance characteristics. You can change the size of 1-dimensional arrays, e.g. doing push!(v,x)
and pop!(v)
.
I think this is the shortest answer A[1:size(A,1) .!= 2,: ]
https://groups.google.com/forum/#!topic/julia-dev/goVB9Pp74H4