row elimination problem.

2 visualizaciones (últimos 30 días)
Anurag Gupta
Anurag Gupta el 19 de Oct. de 2020
Editada: madhan ravi el 19 de Oct. de 2020
Hey
I have a matrix A of 34x2 double.
I want to eliminate the rows wherein the value of both the columns is 0.

Respuesta aceptada

madhan ravi
madhan ravi el 19 de Oct. de 2020
A(all(A == 0, 2), :) = [ ]
  3 comentarios
madhan ravi
madhan ravi el 19 de Oct. de 2020
Editada: madhan ravi el 19 de Oct. de 2020
What?
>> A = [1,2; 0,0]
A(all(A == 0, 2), :) = [ ]
A =
1 2
0 0
A =
1 2
>>
Anurag Gupta
Anurag Gupta el 19 de Oct. de 2020
Editada: madhan ravi el 19 de Oct. de 2020
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

Iniciar sesión para comentar.

Más respuestas (1)

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam el 19 de Oct. de 2020
A(all(A(:,1:2)==0,2),:)=[];
  2 comentarios
madhan ravi
madhan ravi el 19 de Oct. de 2020
How’s this different from my answer?
Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam el 19 de Oct. de 2020
I didn't refresh the web page and the time I submitted the answer, there was no anwser to this question.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by