program to choose 4 columns from 5 column matrix and find determinant in MATLAB

81 Views Asked by At

How can I make a program in MATLAB that will choose 4 columns out of a 5 column matrix and find the determinant from that new 4x4 matrix?

I tried setting each column as a vector with a variable:

a = [1; 2; 3; 4];
b = [5; 6; 7; 8]
c = [9; 0; 1; 2];
d = [3; 4; 5; 6];
e = [7; 8; 9; 0];

I need to make the program choose four out of the five vectors (in any order) and find the determinant.

Any help at all will be appreciated, thanks.

1

There are 1 best solutions below

0
Tony Mathew On

To control which columns the determinant is applied on, combine the columns into a single matrix, then choose the columns using indexing via cols

M = [a b c d e];
cols = [1 3 4 5];
det(M(:,cols))