selective remove lines from array

10 views (last 30 days)
Firas
Firas on 7 May 2014
Answered: Geoff Hayes on 7 May 2014
hi !! some function for this small problem thank you

Answers (1)

Geoff Hayes
Geoff Hayes on 7 May 2014
Firas - if you have a matrix like the following:
Z =
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25
You can remove the 3rd column (say) by simply typing:
% the colon indicates all row elements in the third column should be
% set to the empty matrix (which removes that column)
Z(:,3) = []
Z =
1 6 16 21
2 7 17 22
3 8 18 23
4 9 19 24
5 10 20 25
To remove the 4th row, you do something similar:
Z(4,:) = []
Z =
1 6 16 21
2 7 17 22
3 8 18 23
5 10 20 25
The above is just one way to remove a row or column (line) from a matrix (array).

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!