remove item from array in matlab

To remove an item from an array in MATLAB, you can use indexing and the delete function.

Here's an example code snippet that removes the second item from a vector:

main.m
% create a vector
myVector = [1 2 3 4];

% delete the second item
myVector(2) = [];
84 chars
6 lines

The resulting vector will be: [1 3 4].

You can also use the delete function to remove elements from a matrix. Here's an example code snippet that removes the second row from a matrix:

main.m
% create a matrix
myMatrix = [1 2 3; 4 5 6; 7 8 9];

% delete the second row
myMatrix(2,:) = [];

98 chars
7 lines

The resulting matrix will be:

main.m
1     2     3
7     8     9
28 chars
3 lines

gistlibby LogSnag