Find Function in a for loop - store rows and columns
1 回表示 (過去 30 日間)
古いコメントを表示
for i=1:p
Min_Dis2(exchanges,i)=min(nonzeros(distance2(:,:,i)));
[row,col]=find(distance2(:,:,i)==Min_Dis2(exchanges,i))
end
This is the part of my code which bothers me. When the for loop reaches 'p' i want to have the rows and the columns of each matrix stored. Right now if i run this code i get the row and the column of the last iteration. In other words i need a counter for the rows and columns, something like that [row,col](i), i know that this is not correct, but this is what i need. Thank you in advance!
0 件のコメント
採用された回答
TastyPastry
2015 年 10 月 19 日
Why don't you just find the size of your matrix after your loop?
rows = size(myMat,1);
cols = size(myMat,2);
その他の回答 (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!