# Removing rows from a matrix

I have an array "A" with values:

``````101                 101
0                   0
61.6320000000000    0.725754779522671
73.7000000000000    0.830301150185882
78.2800000000000    0.490917508345341
81.2640000000000    0.602561200211232
82.6880000000000    0.435568593909153
```

```

And I want to remove that first row and keep the shape of the array (2 columns), thus creating an array

``````0                   0
61.6320000000000    0.725754779522671
73.7000000000000    0.830301150185882
78.2800000000000    0.490917508345341
81.2640000000000    0.602561200211232
82.6880000000000    0.435568593909153
```

```

I used `A = A(A~=101);`

one that removes values ​​as needed - however it packs the array down to one column.

+3

source to share

The best way:

``````A = A(2:end, :)
```

```

But you can also do

``````A(1,:) = []
```

```

however, it is slightly less efficient (see Removing matrix elements with = [] and matrix reallocation )

If you want to delete lines that are equal to a certain number try

``````A = A(A(:,1)~=101,:)
```

```

Use `all`

or `any`

if you want to delete a row if any or any column is equal to your value:

``````A = A(all(A~=101,2),:)
```

```
+5

source

All Articles