row elimination problem.

1 次查看(过去 30 天)
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
A(all(A == 0, 2), :) = [ ]
  3 个评论
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
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
I didn't refresh the web page and the time I submitted the answer, there was no anwser to this question.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by