It's because in your second calling of the function
[maxV, minV] = myFunction(volume, bins)
you are setting the first output of your function ('distrib' in your function definition) to the variable 'maxV' and the second output ('maxV' in your function definition) to the variable 'minV'. You can call the first output variable whatever you want when you call the function, and it will take the value of the variable that is called 'distrib' in the function.
To illustrate, try this, for example:
volume = rand(3,3,3,3); bins = 5;
[distrib, maxV, minV] = myFunction(volume, bins);
[maxV, minV] = myFunction(volume, bins);
isequal(distrib, maxV)
Remember that the variable names when you call the function and the variable names inside the function are, in general, completely separate. If you just want to output the 'maxV' and 'minV' variables (the second and third outputs of your function), call it as such:
[~, maxV, minV] = myFunction(volume, bins);
The tilde (~) tells Matlab to skip that output variable.
Best Answer