• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Square Matrix with N sizes.

quotaDestroier

New Member
Hello Chandoo'ers!

I need some help with excel and matrix calculations.
I need to make an spreadsheet that finds the inverse and the determinant of an matrix.
The problem is that, I need to make something that can handle any square matrix be it 2x2, 3x3, 4x4 and so on.

Thanks for the help.
 
If you want to make it dynamic....

You can set up largest Matrix calculation required (ex: 9x9 matrix).
Ex: A1:I9

Then set up MINVERSE range with following formula.
Code:
=IFERROR(INDEX(MINVERSE($A$1:INDEX($A$1:$I$9,COUNT($A$1:$A$9),COUNT($A$1:$I$1))),ROW($A1),COLUMN(A$1)),"")
Fill across and down (ex: M1:U9 )

Then in another cell set up MDETERM.
Code:
=MDETERM($A$1:INDEX($A$1:$I$9,COUNT($A$1:$A$9),COUNT($A$1:$I$1)))

See attached sample.
 

Attachments

  • Matrix_Calc.xlsx
    11.4 KB · Views: 9
One thing I would do is stay clear of the conventional worksheet environment for the formulas; implicit intersection is designed to make a mess of array formulas. If you name your array 'matrix' then further names 'determinant' and 'inverse' can be defined to refer to
= MDETERM(matrix)
and
= MINVERSE(matrix)
respectively.

Only if you are using Office 365 insider will the results of these named formulas display correctly (Dynamic Arrays). Otherwise you need to build an oversize output array using CSE and mask the excess rows and columns.
= IF( mask, inverse, "" )
where 'mask' refers to
= {1;1;1;1;0}*{1,1,1,1,0}

That leaves you with the problem of creating the named array 'matrix' dynamically. I find a convenient way of doing this is to use a Table. Deselect the headers, filters and banded rows and you get close to something useful.
 

Attachments

  • MatrixInversion.xlsx
    16.7 KB · Views: 7
Last edited:
Back
Top