문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top