@Jan Simon - Please try:
rand('state',0);
x = rand(3,3,3);
[value, pos] = max(x(:));
index = ind2sub(pos, size(x));

You will get
index =
3 3 3

Which is incorrect. Infact, your usage of ind2sub is incorrect. Please look at the help. If you use it the correct way which is
>> ind2sub(size(x),pos)
then the problem is you need to use it as
>> [r,c,h] = ind2sub(size(x),pos)
So, you need to know how many output arguments to use based on the dimensions of x. Notice that the myind2sub subfunction in mDmax takes care of this and so now you can use any dimensional matrix as input for mDmax.

@Naresh: Thanks for your answer. You are right, I've confused the order of arguments for IND2SUB.
Do I understand correctly, that the benefit of your function is a smarter IND2SUB function, which replies a vector instead of a list of indicies? If so, it might be more useful for others, if you post this improved IND2SUB explicitly, while the MAX(X(:)) part is trivial and could be omitted. There is a need for a modified IND2SUB, see e.g. http://www.mathworks.com/matlabcentral/newsreader/view_thread/236782 and http://www.mathworks.com/matlabcentral/answers/23599 .

@Jan Simon - Please try:
rand('state',0);
x = rand(3,3,3);
[value, pos] = max(x(:));
index = ind2sub(pos, size(x));

You will get
index =
3 3 3

Which is incorrect. Infact, your usage of ind2sub is incorrect. Please look at the help. If you use it the correct way which is
>> ind2sub(size(x),pos)
then the problem is you need to use it as
>> [r,c,h] = ind2sub(size(x),pos)
So, you need to know how many output arguments to use based on the dimensions of x. Notice that the myind2sub subfunction in mDmax takes care of this and so now you can use any dimensional matrix as input for mDmax.