Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

how to reject whole columns based on a condition

1 visualización (últimos 30 días)
omar mahallawy
omar mahallawy el 14 de Mzo. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
A = [5 10 18 13
-2 8 -9 10
40 47 85 -30]
condiotion : remove columns with any negative numbers
result=[10
8
47]
kindly note that this is in a for loop

Respuestas (1)

Akira Agata
Akira Agata el 14 de Mzo. de 2019
No need to use for-loop. Please try the following:
A = [5 10 18 13;
-2 8 -9 10;
40 47 85 -30];
idx = any(A<0);
result = A(:,~idx);

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by