
Working w ith Matrices
Deleting Rows an
dColumns
You can delete ro
ws and columns from a matrix using just a pair of square
brackets. Start
with
X=A;
Then, to delete t
he second column of
X,use
X(:,2) = []
This changes X to
X=
16 2 13
511 8
9712
414 1
If you d elete a si
ngle element from a matrix, the result is not a matrix
anymore. So, exp
ressions like
X(1,2) = []
result in an erro
r. Howev e r, usin g a single subscript deletes a single element,
or sequence of e
lements, and reshapes the remaining elements into a row
vector. So
X(2:2:10) = []
results in
X=
1692713121
2-19
Komentarze do niniejszej Instrukcji