Clear Filters
Clear Filters

Find the min for each plane of a multidimensional array

2 views (last 30 days)
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!

Answers (1)

Bob Thompson
Bob Thompson on 28 Feb 2019
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.

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!