How do I find the maximum/last index value from a list of indices
3 ビュー (過去 30 日間)
古いコメントを表示
I have imported some data to form an array called 'newData1.data' and then find the row/col indices for each value 1-49 in a vector called 'numbers'
numbers=1:1:49;
for i=1:length(numbers)
[row,col] = find(newData1.data' == i);
end
How do I find the greatest/maximum/last column number?
test(i) = max(col)
does not work within the loop. There are plenty of questions and answers on how to get the indices of the maximum value in the array, but that is not what I am looking for.
Best regards,
Alex
0 件のコメント
採用された回答
Image Analyst
2016 年 12 月 24 日
Try this:
numbers = 1 : 1 : 49;
for k = 1 : length(numbers)
[rows, columns] = find(newData1.data' == numbers(k));
maxColumns(k) = max(columns)
end
2 件のコメント
Image Analyst
2016 年 12 月 24 日
It's not exactly the same thing you were doing since my code is more robust in that it compares "numbers" instead of i. Your code defines numbers but then never uses it. Anyway there is nothing wrong so the only way we can continue is if you attach your data via a .mat file.
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!