Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Chuguang Pan
Chuguang Pan il 13 Dic 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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by