How can I use a for loop to select values from a table that meet two conditions?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Chuguang Pan
2019-12-13
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!