How can I delete some rows of a matrix

1 回表示 (過去 30 日間)
mr mo
mr mo 2017 年 11 月 9 日
コメント済み: mr mo 2017 年 11 月 9 日
Hi. Suppose I have matrix A e.g.
A=[8.2505 4.8825 2.2563 0.0020 0
8.2505 4.8825 2.2687 0.0020 1
8.2505 4.8825 2.2813 0.0020 2
8.2505 4.9325 2.2813 0.0020 0
8.2505 4.9325 2.2938 0.0020 3
8.2755 4.7575 2.2437 0.0020 0
8.2755 4.7575 2.2563 0.0020 0
8.2755 4.7575 2.2687 0.0020 2
8.2755 4.8075 2.2188 0.0020 0
8.2755 4.8075 2.2313 0.0020 3
8.2755 4.8075 2.2437 0.0020 1
8.2755 4.8075 2.2563 0.0010 0
8.2755 4.8075 2.2687 0.0010 2];
I want to delete the rows that their fifth column values are unequal to 0 and at the end I want to have the new matrix A without these rows.
Thanks a lot.
  2 件のコメント
dpb
dpb 2017 年 11 月 9 日
Which leaves a column of zeros???
mr mo
mr mo 2017 年 11 月 9 日
At the end I want this :
A=[8.2505 4.8825 2.2563 0.0020 0
8.2505 4.9325 2.2813 0.0020 0
8.2755 4.7575 2.2437 0.0020 0
8.2755 4.7575 2.2563 0.0020 0
8.2755 4.8075 2.2188 0.0020 0
8.2755 4.8075 2.2563 0.0010 0];

サインインしてコメントする。

採用された回答

James Tursa
James Tursa 2017 年 11 月 9 日
編集済み: James Tursa 2017 年 11 月 9 日
A = A(A(:,5)==0,:);
or
A(A(:,5)~=0,:) = [];
  4 件のコメント
James Tursa
James Tursa 2017 年 11 月 9 日
This code gives the desired result you posted above. So I am not certain what the problem is at this point.
mr mo
mr mo 2017 年 11 月 9 日
I made a little mistake. you're right. Thanks a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by