View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Inversion every 2D slice for arbitrary Multi-dimension array.

5.0 | 4 ratings Rate this file 8 Downloads (last 30 days) File Size: 2.37 KB File ID: #31222 Version: 1.0

Inversion every 2D slice for arbitrary Multi-dimension array.


Xiaodong (view profile)


Inverse every 2D slice for an arbitrary N-D array (M).

| Watch this File

File Information

Inverse every 2D matrix slice (the first two dimensions) for multi-dimensional array M:
  M(:,:,p,q,...) * X(:,:,p,q,...) = repmat(eye(m),[1,1,p,q,...]),
where input M is a N-D array (m x m x [p x q x ...]), for all possible m=1,2,3,...
and optional higher dimensions. Output X array has the same size as M.


Multiple Matrix Multiplications, With Array Expansion Enabled and Multiple Same Size Linear Solver inspired this file.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
26 Jan 2017 Antonio Mei

Terrific work and thanks for sharing! Do you have a similar function for determinants of nxnxp matrices?

Comment only
28 Apr 2016 Xiaodong

Xiaodong (view profile)

Hi llan, can you comment on the error message for what was not working? This program is optimized for this specific task in terms of performance and memory consumption. It may have a warning which can be ignored if you use integers for all array elements, but I don't find any other issues so far. For example, to produce the warning:

>> A=ones(3,3,20,200);
>> B=multinv(A);
Warning: Matrix is singular to working precision.
> In multinv (line 73)

Comment only
27 Apr 2016 Ilan

Ilan (view profile)

Does not work on matlab 2015b

Comment only
24 Oct 2015 Yuan Zhou

26 Feb 2015 Sean

Sean (view profile)

18 Feb 2013 Rajab Legnain

Hi Sir

It is early a great function.
Thanks for sharing.

04 Jun 2012 Clay Fulcher

This program works GREAT! It greatly improved the speed of my codes that require inversion of matrices of functions. I use it with mtimesx. Thanks for your effort on this code, Xiaodong.

28 Apr 2011 Paolo de Leva

Paolo de Leva (view profile)

Thank you for your comment on

Your function is quite useful as it is. However, to be compatible with MULTIPROD, and to meet the requirements to be an ARRAYLAB function, it should work with any block array of square matrices, not only with those containing square matrices along their first two dimensions. Thus, it should have a syntax similar to MULTITRANSP (provided together with MULTIPROD).

My best regards.

Comment only

Contact us