Karhunen Loeve expansion is a representation of a stochastic process as sum of an infinite series of terms which are product of random variables and orthogonal functions:

As we know, a Wiener process Xt is characterized by the following properties:
1.Expected value of Xt i.e., E[Xt]=0
2.Variance is t
Here we demonstrate how KL expansion can be used for generating Wiener process paths.
A rescaled Wiener process has the following representation:

In the attached matlab program we generate IID random variables and use this formula to generate Wiener process paths. Instead of using no. of expansion terms to infinity, we restrict it to value of nk.
After doing simulations, we verify that as the no. of expansion terms increase, the simulated process converges to mean 0 and variance t. Note that t should be between 0 and 1.
Section 4.4 in this paper has nice explanation on derivation of expansion formula :
http://www.cims.nyu.edu/~eve2/chap4.pdf