function M = smat(v) %Generate a symmetrix matrix with size n from the column vector of size %n(n+1)/2. [ntilde,m]=size(v); counter=0; n=round((-1+sqrt(1+8*ntilde))/2); for j=1:n for i=j:n if (i==j) M(i,j)=v(counter+i-j+1); else M(i,j)=v(counter+i-j+1)/sqrt(2); end M(j,i)=M(i,j); end counter=counter+n-j+1; end