Borrar filtros
Borrar filtros

How can I use a for loop to select values from a table that meet two conditions?

2 visualizaciones (últimos 30 días)
My table is tab=table(metabolites, aerobic, anaerobic).
I am trying to compute a for loop that only selects those metabolites where they are >=0 in each aerobic and anaerobic columns and where they also different value in each column for each row.
I am not too sure how I can change the below for loop to say the above, as it is currently wrong. I would be grateful for any suggestions please. Thank-you
m=1
for i=1:height(tab)
if(Aerobic(i)~=Anaerobic(i)) &
(Aerobic(i) & Anaerobic(i) >=0)
secmet(m, 1:3)=tab(i, 1:3)
m=m+1
else
continue;
end
end

Respuesta aceptada

Chuguang Pan
Chuguang Pan el 13 de Dic. de 2019
m=1;
for i=1:height(tab)
if(Aerobic(i)~=Anaerobic(i)) && Aerobic(i)>=0 && Anaerobic(i)>=0
secmet(m, 1:3)=tab(i, 1:3)
m=m+1
else
continue;
end
end
Just need to change the logical expresssion

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by