MATLAB: Is there faster way to apply `det` function along the third dimension

bsxfunfor loopMATLABspeed

I am trying to calculate the det of many 4*4 matrix. I store the data in a matrix with shape 4*4*n. (n =4000000). I am using the for loop to get the result as below. Is there any way to accelerate the progress? Like bsxfun or arrayfun, or some simillar ideas?
v = zeros(length(m),1);
for i=1:size(m,3)
v(i)=det(m(:,:,i));
end

Best Answer

I would note that Walter's solution that use recursive formal determinant formula might be fast but might be sensitive to umerical errors, that is how I was tough (for medium/large size matrix).