selective remove lines from array

조회 수: 10 (최근 30일)
Firas
Firas 2014년 5월 7일
답변: Geoff Hayes 2014년 5월 7일
hi !! some function for this small problem thank you

답변 (1개)

Geoff Hayes
Geoff Hayes 2014년 5월 7일
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).

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by