Eliminating matrix row on condition

1 回表示 (過去 30 日間)
arun Dhillon
arun Dhillon 2019 年 5 月 14 日
コメント済み: arun Dhillon 2019 年 5 月 14 日
I have an m*5 matrix. I am using
if min(abs(matrix(1,:)))==0
matrix(1,:)=[]
To eliminate the first row, if any of the element in the first row is equal to 0.
My questions is, that lets say we have an m*5 matrix. What I want to do is to eliminate the row or rows that has any element inside of it equal to 0. In other words, lets say I have 5*5 matrix. The 2 row has 2 element(2,2) =0, and the 3rd row has 4th (3,4) =0, what I would like to do is that the entire 2nd and 3rd row should be eliminated, as they were having one of the element in their respective row equal to 0.
Please edify for how can I do the same for m no. of rows for to eliminate, any row that has any element=0.

採用された回答

KSSV
KSSV 2019 年 5 月 14 日
A = [1 2 0 ; 3 4 0 ; 5 6 7; 8 9 10]
A(any(A==0,2),:)=[]
  1 件のコメント
arun Dhillon
arun Dhillon 2019 年 5 月 14 日
Thank you so much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by