 <p>Here's a workaround:</p> <p>Replace all the 0s in Z by NaN, calculate the min, then switch back to 0:</p> <pre><code>clear all clc close all Z(:,:,1) = [-5 0 5 0 0 0 1 0 3]; Z(:,:,2) = [1 0 2 0 0 0 0 0 0]; Z(:,:,3) = [0 0 0 -9 0 4 0 0 0]; Z(:,:,4) = [0 0 0 -2 0 0 0 0 0]; %// Assign NaN to 0 elements Z(Z ==0) = NaN; Zmin = min(Z,[],3); %// Switch back with 0 Zmin(isnan(Zmin)) = 0; %// Same for Z; Z(isnan(Z)) =0; </code></pre> <p>The output looks like this:</p> <pre><code>Zmin Z Zmin = -5 0 2 -9 0 4 1 0 3 Z(:,:,1) = -5 0 5 0 0 0 1 0 3 Z(:,:,2) = 1 0 2 0 0 0 0 0 0 Z(:,:,3) = 0 0 0 -9 0 4 0 0 0 Z(:,:,4) = 0 0 0 -2 0 0 0 0 0 </code></pre>