%genrandn.m
function [RES,C1]=genrandn(m,C,N)
%m is the meanvector (column vector)
%C is the intended co-variance matrix%N is the number
%of data
%C1 is the estimate of the co-variance matrix
%computed using the generated
%data
DATA=randn(N,length(m));
[E,D]=eig(C);
RES=E*D.^(1/2)*DATA';
RES=real(RES)+m;
%Check the covariance matrix
C1=real(cov(RES'));