Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a row of matrix in julia

Tags:

matlab

julia

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,:) = []. but I failed. How to solve this problem?

like image 208
user2405694 Avatar asked Jun 25 '13 13:06

user2405694


People also ask

How do you delete a row array?

Using the NumPy function np. delete() , you can delete any row and column from the NumPy array ndarray . Specify the axis (dimension) and position (row number, column number, etc.). It is also possible to select multiple rows and columns using a slice or a list.

How do you delete a row?

Right-click in a table cell, row, or column you want to delete. On the menu, click Delete Cells. To delete one cell, choose Shift cells left or Shift cells up. To delete the row, click Delete entire row.

How do I remove an element from an array in Julia?

We can do this with the deleteat! function. (It looks like the function name is “delete eat” but it's actually “delete at” 😂). You can also delete a range of elements from an array using deleteat!()

How do you delete a column in a matrix?

The easiest way to remove a row or column from a matrix is to set that row or column equal to a pair of empty square brackets [] . For example, create a 4-by-4 matrix and remove the second row.


1 Answers

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).

like image 72
StefanKarpinski Avatar answered Sep 21 '22 20:09

StefanKarpinski