2

I have a matrix m*n, I want from it all the minors (the determinant of the submatrices) of order p.

I din't found anything good in the documentation, I could do it with a function written by my self, but I'd prefer something out of the box.

My real need is to check when,in a symbolic matrix, I have a fall of rank,and that happens when all the minors of that rank and above are zeros.

Any idea to do it with pure matlab comands? since there is a function to evalutate rank it has get the minors someway.

user1834153
  • 330
  • 5
  • 20
  • Can't you just use `rank`? – Luis Mendo Jan 01 '14 at 23:41
  • @LuisMendo, Hi Luis, the matrix rank gives the number of linearly independent rows (or columns) of a matrix while the (i-th,j-th) matrix minor is the determinate calculated from A's sub-matrix with the (i-th,j-th) row, column removed. Not sure how the rank would be related to the minor. – Bruce Dean Jan 01 '14 at 23:57
  • @roybatty Because the OP says "My real need is to check when,in a symbolic matrix, I have a fall of rank,and that happens when all the minors of that rank and above are zeros." – Luis Mendo Jan 02 '14 at 00:05
  • @LuisMendo, Ok good point Luis, I just figured that having the minors might still be useful to the OP, but otherwise, then yes, perhaps the rank is all that is needed. – Bruce Dean Jan 02 '14 at 00:09
  • my matrix is symbolic,rank gives me the number of indipendent rows(colums) if I evalutate the matrix. it doesn't give me the condition from wich I can check when my rank reduces,those are the minors==0 – user1834153 Jan 02 '14 at 19:21

3 Answers3

2

There appear to be some good answers already, but here is a simple explanation of what you can do:

Suppose you want to know the rank of every i-jth submatrix of a matrix M.

Now i believe the simplest way to get all ranks is to loop over all rows and columns and store this result in a matrix R.

M = magic(5);
R = NaN(size(M));
for i=1:size(M,1);
  for j=1:size(M,2);
    R(i,j) = rank(M([1:i-1 i+1:end],[1:j-1 j+1:end]));
  end
end

If you want all determinants replace rank with det.

Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122
  • that's clever, I love the way you get the submatrix...improving this one I'm sure I can solve it simpler than I tought – user1834153 Jan 02 '14 at 19:26
1

This calculates the submatrix:

submatrix=@(M,r,c)M([1:r-1,r+1:end],[1:c-1,c+1:end])

You may either use 'arrayfun' and 'meshgrid' or two loops to iterate over all submatrices.

Daniel
  • 36,610
  • 3
  • 36
  • 69
  • if the matrix is square I totally agree with you...will look into adapt this method for a rectangular one. thanks – user1834153 Jan 02 '14 at 19:27
0

Caveat: I don't have the Symbolic Toolbox but for a regular matlab array you can calculate the i-th, j-th minor with an anonymous function like this:

minor = @(i,j,A)det(A(setdiff([1:end],[i]),setdiff([1:end],[j])))

Or if you want the i-th, j-th cofactor, simply use:

cofactor = @(i,j,A)(-1)^(i+j)*det(A(setdiff([1:end],[i]),setdiff([1:end],[j])))

But as mentioned I don't know if something like this will work with the Symbolic Toolbox. If it does not work as-is, perhaps this can at least give you some ideas on how you might implement the function for the symbolic case.

Hope this helps.

Bruce Dean
  • 2,798
  • 2
  • 18
  • 30
  • yes,thanks, that was pretty much what I had in mind to implement it...but of course it only works for n+n matrix in your case...with a bit of coding using your idea it can be done – user1834153 Jan 02 '14 at 19:23