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 Comment

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

Sign in to comment.

 Accepted Answer

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 Comments

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

Sign in to comment.

More Answers (0)

Asked:

on 5 Oct 2014

Commented:

on 5 Oct 2014

Community Treasure Hunt

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

Start Hunting!