Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove elements at a set of indices in a vector in MATLAB?

I have a vector with 100 elements. I have another vector with index positions of elements I want to remove from this vector.

How do I do this?

like image 220
Ted Flethuseo Avatar asked Sep 24 '10 18:09

Ted Flethuseo


People also ask

How do you delete an element from a matrix in MATLAB?

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. Now remove the third column.

How do you delete a data point in MATLAB?

Click a point that you want to exclude in the fit plot or residuals plot. Alternatively, click and drag to define a rectangle and remove all enclosed points.

How do you select an element from an array in MATLAB?

To access elements in a range of rows or columns, use the colon . For example, access the elements in the first through third row and the second through fourth column of A . An alternative way to compute r is to use the keyword end to specify the second column through the last column.


1 Answers

vector(indecies) = [] 

example:

>> a = 1:10; >> a([3,4,7]) = []  a =       1     2     5     6     8     9    10 
like image 190
second Avatar answered Sep 21 '22 01:09

second