MATLAB: Problems on doing the combination of two variables (columns) in a matrix.

2variablescombinationcombinationofcolumnsmatrixcombination

I have to obtain a test statistics from an equation (T), for a thermodynamic process. Fk matrix is made of variables (columns) and constraints (rows). In my code the only changing matrix would be Fk, so I have to obtain the test for all the possible combinations of 2 variables of Fk(15×2) without repeating any.
the combination of the variables should be like this (where this variables are the columns of Fk):
1,2
1,3
1,4
1,5
1,6
2,3
2,4
2,5
2,6
3,4
……
5,6
I attach here the Excel file of the measured values of the variables from 1 to 6 and the matlab code I have done for the combination of one variable.
Does anybody know how should be the code for all the combinations like this?

Best Answer

nchoosek is your friend:
combinations = nchoosek(1:size(Fk, 2), 2);
for combination = combinations'
var1 = Fk(:, combination(1));
var2 = Fk(:, combination(2));
%do something with var1 and var2
end