B=[1 2 3 4 5 6 7; 9 11 13 15 17 19 21];for i=1:7 for j=1:7 if i>jP=B(:,i);Q=B(:,j);Norm=zeros(1,nchoosek(7,2));d=norm(P-Q)k=1:nchoosek(7,2);Norm(:,k)=d end endend
MATLAB: How to create a 1×21 matrix where the inputs are all the different values of d
arrayfor loop
Best Answer