Looping over column and returning values where conditions are met
12 ビュー (過去 30 日間)
古いコメントを表示
I want to loop over a first column (which is column numbers) and return the values when the conditions are met for the next 4 columns. I already have a loop that finds the count of columns that meet conditions but I want it to return the first column values. For example in the image below the highlighted rows are the conditions that are satified and I want to find and reutrn the row numbers (3,5,6 and 9).
回答 (1 件)
James Tursa
2020 年 4 月 5 日
In general, perform find( ) on the condition you want. E.g.,
find(matrix(:,4)>80)
would return the row numbers where the 4th column is greater than 80.
4 件のコメント
James Tursa
2020 年 4 月 5 日
Sure. If your loop index k is looping over the rows, then you could test within the loop
if( matrix(k,4)>80 & matrix(k,3)<350 )
% do something
end
参考
カテゴリ
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!