you should use the 'reshape' command: transform the 'a x b x c x d' array (with d=4) into an matrix of size 'E x d' and take the mean of that.
so lets say M has dim (55,128,18,4) then reshape(M,[],4) will put all the entries of M into a (55*128*18) by 4 matrix. Taking the mean of that gives you the answer. So
Avg_4th_dim=mean(reshape(M,[],4));
Note that the 4 in the reshape command does not refer to the dimension, but size of the 4th dimension.