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 Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by