%%% Program by Hammad Munawar (www.hammadmunawar.weebly.com) %%% IAA, Islamabad, Pakistan % %%% Create two random vectors with mean=100,sd=10,correlation=0.5 % mean=100;%mean sd=10;%standard deviation corr_mat=[1 0.5;0.5 1];%correlation matrix L=chol(corr_mat);%cholesky factorization U=mean+sd.*rand(100,2);%generate random vectors with specified mean and sd U=U*L;%set correlations x=U(:,1);%first random vector y=U(:,2);%second random vector corr(x,y)%verify correlation