polyfitn function fits a general polynomial regression model in n dimensions. You have implemented the loop in getting the results for all metriche (your variable name). For getting the results for every 2 possible combination, you can try two ways :
First, just add two for loops to get each element correspond to every other element like:
for ele1 = 1: numel(metriche, 2)
for ele2 = ele1 : numel(metriche, 2)
data = [ele1; ele2];
% Your code
end
end
Second, you can use an inbuilt MATLAB function, combnk, to get enumeration of the combinations of your vector. You need to pass the vector and the number of elements you want to take at a time.
I am attaching some links for your reference on polyfitn and combnk. Please refer to the following links for more details: