How can i get the index of the submatrix D, that correspond to the maximum determinant?

I have this code
A= randn(2, 4);%this will give me a 2rows by 4columns matrix
b=0;
for i=1:1:4
for j=(i+1):1:4
b=b+1;
D=[A(:,i),A(:,j)];
E(b)=det(D);
end
end
F=max(E);
From the code a submatrix D is designed for each iteration F will return the maximum determinant after all itereations. But please, how can i get the index [i ; j] that made up the matrix D which correspond to F

댓글 수: 1

Please i will be greatful if anyone can just edit the code to help me achieve my aim thanks in anticipation

댓글을 달려면 로그인하십시오.

 채택된 답변

A = randn(2,4);%this will give me a 2rows by 4columns matrix
b = 0;
for i=1:1:4
for j=(i+1):1:4
b=b+1;
D=[A(:,i),A(:,j)];
E(b)=det(D);
G(b,:) = [i,j]; % <---
end
end
[F,b] = max(E); % <---
[i,j] = G(b,:); % <---

댓글 수: 3

thanks but i keep getting this error message
Indexing cannot yield multiple results.
Error in testingcode (line 12) [i,j] = G(b,:); % <---
Change the last line to:
i = G(b,1); j = G(b,2);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2014년 10월 5일

댓글:

2014년 10월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by