Find the min for each plane of a multidimensional array

2 次查看(过去 30 天)
Hi all!
I would like to find the position and the min value for each plane of a multidimensional array (a stack).
The minimum value must be found considering the minimum of each plane and therefore not an absolute minimum because it must be in the same position for each plane.
Thank you!

回答(1 个)

Bob Thompson
Bob Thompson 2019-2-28
A = randi(100,3,3,3); % Sample input
[m,r] = min(A,[],1); % Locate minimum value for all rows
[m,c] = min(m,[],2); % Locate minimum column from row minimums
for i = 1:size(A,3); % Loop through each sheet to combine index
idx(:,:,i) = [r(:,c(:,:,i),i),c(:,:,i)]; Combine for ordered pair
end
So, minimum has the ability to determine minimums along a specified dimension. Unfortunately, unlike max(), it can only be done along one dimension at a time.

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by