Find the maximum in my array
2 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Jan
2017-3-14
编辑:Jan
2017-3-14
A = rand(x, y, z);
[maxValue, maxIndex] = max(A(:));
[ix, iy, iz] = ind2sub([x, y, z], maxIndex);
[EDITED] Here "A" was created only as test data only. If you have the array already, you need the size() command to obtain the dimensions:
[maxValue, maxIndex] = max(A(:));
[ix, iy, iz] = ind2sub(size(A), maxIndex);
3 个评论
Jan
2017-3-14
See [EDITED]. Not that "A(:)" is a vector, while "A(:, :, :)" is not and the shown method does not work.
更多回答(1 个)
Auryn_
2017-3-14
2 个评论
Jan
2017-3-14
Please open a new thread for a new question to avoid confusing the readers. Thanks.
The answer might be something like:
Index = find(0 < A & A < 1);
[ix, iy, iz] = ind2sub(size(A), Index)
Sigh, now I've answered already. So obviously I'm the first person who is confused ;-)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!