Here is an example using four random variables. (It would be analogous to just your variables W1,W2,W4,W5.) It generates 100 observations of these four variables.
N = 100;
mu = [0 0 0 0];
sigma = [ ...
1.0 0.9 0.9 0.8; ...
0.9 1.0 0.8 0.9; ...
0.9 0.8 1.0 0.9; ...
0.8 0.9 0.9 1.0; ...
];
r = mvnrnd(mu,sigma,N)
Note how in the correlation matrix sigma, I've made nearest-neighbors have a correlation of 0.9, and the diagonally connected ones have 0.8. I think this captures the gist of what you were trying to do.
So, for your nine-variable case, you will need to define sigma as a 9x9 correlation matrix, and mu as a 1x9 vector of means.
An important thing to note is that the matrix needs to be "positive definite". Practically speaking, this means that your correlations need to be self-consistent with each other. For example, in your case, if (W1,W2) have 0.9 correlation, and (W2,W4) have 0.9 correlation, then it will not be possible for (W1,W4) to have a small correlation like 0.4. mvnrnd will give an error message if you try to define a non-sensible correlation matrix like that.
I hope that helps.
Best Answer