Hey
I have a matrix A of 34x2 double.
I want to eliminate the rows wherein the value of both the columns is 0.

 採用された回答

madhan ravi
madhan ravi 2020 年 10 月 19 日

1 投票

A(all(A == 0, 2), :) = [ ]

3 件のコメント

Anurag Gupta
Anurag Gupta 2020 年 10 月 19 日
it is not returning me a A as a matrix, it is getting converted to a vector.
madhan ravi
madhan ravi 2020 年 10 月 19 日
編集済み: madhan ravi 2020 年 10 月 19 日
What?
>> A = [1,2; 0,0]
A(all(A == 0, 2), :) = [ ]
A =
1 2
0 0
A =
1 2
>>
Anurag Gupta
Anurag Gupta 2020 年 10 月 19 日
編集済み: madhan ravi 2020 年 10 月 19 日
Hello Madhan,
Extremely sorry I actually made an error earlier in the loop which lead to me not getting the right answer. Thanks a lot for the solution. It worked perfectly.
Regards,
Anurag Gupta

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

その他の回答 (1 件)

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam 2020 年 10 月 19 日

0 投票

A(all(A(:,1:2)==0,2),:)=[];

2 件のコメント

madhan ravi
madhan ravi 2020 年 10 月 19 日
How’s this different from my answer?
Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam 2020 年 10 月 19 日
I didn't refresh the web page and the time I submitted the answer, there was no anwser to this question.

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

質問済み:

2020 年 10 月 19 日

編集済み:

2020 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by