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