# Find minors of a rectangular matrix

12 views (last 30 days)

Show older comments

### Answers (2)

John D'Errico
on 12 Jul 2022

Edited: John D'Errico
on 12 Jul 2022

Sadly, it is often true that people ask confusing questions, using their own terminology, jargon they have picked up that is often not standard. I'll assume that you know what a minor is for my answer, although it is entirely possible you are thinking something different.

A minor of a matrix is what remains of the matrix when you have removed one row and one column. So the minors of a rectangular matrix will also be rectangular. If the matrix was not square, then so will be the minor you have chosen.

However, you need to recognize there will be MANY such minors, depending on the size of your matrix. That is, for ANY element of the matrix, there will be a corresponding minor, since that element denotes a specific row and column. For an nxm matrix, there will be n*m minors, and each will be an (n-1)x(m-1) matrix.

One could certainly use a simple loop to create all of them. Perhaps storing them in a cell array. Or you could even store them all in the higher order planes of a 4-dimensional array. However, I fail to see a simple solution that would be better than a direct pair of nested loops to create them all. For example, your 3x2 array will have 6 minors, all of which are 2x1 arrays (actually, in this case, vectors).

A = randi(6,[3,2]) % choosing a random 3x2 matrix

allminors(A)

The code I wrote is not inefficient at all. It preallocates the array Aminors, so even for larger problems, there will be no problem. So if A is larger, it is still reasonably fast. Loops are not always a bad thing in MATLAB, as long as you understand how to use them properly.

A = randi(9,[50,100]);

B = allminors(A);

size(B)

timeit(@() allminors(A))

What you will do with them all is your problem. Though in the back of my mind, I still wonder if you do know what is a minor, or if you have good reasons for wanting to do this. Sorry, but when people ask basic questions like this using jargon that students often misuse, that is a distinct possibility. Perhaps you wanted to compute the determinants of the square minors. I cannot know.

function Aminors = allminors(A)

% generate all minors of a matrix

[n,m] = size(A);

Aminors = zeros(n-1,m-1,n,m);

deleteindex = @(ind,p) setdiff(1:p,ind);

for i = 1:n

for j = 1:m

Aminors(:,:,i,j) = A(deleteindex(i,n),deleteindex(j,m));

end

end

end

##### 3 Comments

Bjorn Gustavsson
on 12 Jul 2022

Bjorn Gustavsson
on 12 Jul 2022

Edited: Bjorn Gustavsson
on 12 Jul 2022

As far as I understand this one definition of generating one k-minor from an arbitrary matrix of size n-by-m is to select k rows and k columns, where k is smaller than both n and m. (There will be a rather large number of minors for larger matrices). One way to calculate that is:

function Minor = Mminor(M,I1,I2)

% Minor - calculate one matrix-minor

% Calling:

% Minor = Mminor(M,I1,I2)

% Input:

% M - double matrix, [n x m]

% I1 - row-index-array, positive integer array [1 x k], or [k x 1]

% I2 - column-index-array, positive integer array [1 x k], or [k x 1]

% Output

% Minor - det(M(I1,I2)), one matrix minor.

% Example:

% I1 = [1 2 4 6];

% I2 = [2 3 4 5];

% M = randn(7,5);

% M1 = Mminor(M,I1,I2)

% det(M(I1,I2))

% The largest element in I1 has to be smaller than or equal to n, the

% largest element in I2 has to be smaller than or equal to m

%

Minor = det(M(I1,I2));

end

You will have to introduce error-checks and other stuff.

HTH

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!