How to find every principal submatrix of a matrix. (given input row and column indices)
조회 수: 21 (최근 30일)
이전 댓글 표시
I am curious as to find out how I can write so that given a square matrix, the program can compute "every" principal submatrix of the matrix.
I know how to find the basic ones; for example, given a 5x5 square matrix, finding principal submatrix by deleting same row and column. But I am struggling to find a principal matrix of let's say deleting 1st and 3rd row and column and etc.
How can I write this into a matlab code?
Thanks for any tips in advance!
댓글 수: 2
Steven Lord
2023년 5월 21일
How large are the matrices for which you want to perform this operation? If they're too large, you may not have enough memory to store the results and it may take an infeasible amount of time to compute all of them.
답변 (1개)
KSSV
2023년 5월 21일
You can delete 1, 3 rd row and column from 5x5 matrix using:
A = rand(5) ;
A([1 3],:) = [] ; % delete 1st and 3rd row
A(:,[1 3]) = [] ; % delete 1st and 3rd column
댓글 수: 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!