generating a Gaussian dataset in MATLAB I want to generate a Gaussian dataset. The dataset includes a total of 800 samples drawn randomly from four two-dimensional Gaussian classes with following distribution:

How can I do that in MATLAB? I'm not expert in MATLAB.
 A: This question is more appropriate for Stack Overflow, but that's OK. It still is a mathematics question, after all.
The right way to do this in Matlab is to use the mvnrnd() function. It accepts a vector of the coordinate means and a covariance matrix, and can return the results into an array of any shape that you'd like. In your care, you'd do the following:
mi = -3;                         % Or the other values you want to use.
mu = [mi 0];                     % The mean vector.
cov_mat = [0.5 0.05; 0.05 0.5];  % The covariance matrix.

num_samples = 800;               % The number of samples you want.

% Generate the draws.
generated_data = mvnrnd(mu, cov_mat, num_samples);

Now, the array generated_data will be an 800-by-2 matrix, where each row is a random draw from the distribution. See this link for more details. 
Note that this claims to be part of the Matlab Statistics Toolbox. This should be a standard part of most Matlab licenses at an academic or professional institution. However, if you're using a personal copy of Matlab (such as the student version), you may not have access. In that case, there are several basic implementations of the same function available at the Matlab Central File Exchange, which you can download and use.
If that still doesn't work, let me know in a comment and I can go over the algorithm for actually drawing from a multivariate Gaussian based only on the inverse-CDF method and uniform draws.
Alternatively, much of the same functionality is provided in SciPy/NumPy for Python. It's free and is a good alternative to learn given that not much practical mathematical software is ever developed in Matlab.
Added:
As you mentioned not having the Statistics Toolbox, and then downloading the linked mvg() function from the file exchange, here is the code that would work with that function:
mi = -3;                        % Or the other values you want to use.
mu = [mi 0];                    % The mean vector.
cov_mat = [0.5 0.05; 0.05 0.5]  % The covariance matrix.

num_samples = 800;              % The number of samples you want.

% Generate the draws.
generated_data = mvg(mu, cov_mat, num_samples)

This time, generated_data will be a 2-by-800 array, so each column will be a random sample, instead of the rows as listed above.
You may want to try this for a smaller number of samples, like 10 or 15, and then just print out the result by typing:
generated_data

without a semicolon, to see what the output array looks like.
A: The finite-dimensional version of the spectral theorem implies that a symmetric nonnegative-definite matrix $\Sigma$ with real entries as a symmetric nonnegative-definite square root $\Sigma^{1/2}$.  Say the variance (or "covariance matrix", if you like) is a $2\times2$ matrix
$$
\Sigma = \begin{bmatrix} \sigma^2 & \rho\sigma\tau \\  \rho\sigma\tau & \tau^2  \end{bmatrix} = \begin{bmatrix} \sigma & 0 \\  0 & \tau  \end{bmatrix}\begin{bmatrix} 1 & \rho \\  \rho & 1  \end{bmatrix}\begin{bmatrix} \sigma & 0 \\  0 & \tau  \end{bmatrix}.\tag{1}
$$
If $U$, $V$ are independent standard $1$-dimensional Gaussian random variables (thus the variance of the random vector $\begin{bmatrix} U \\  V \end{bmatrix}$ is the $2\times2$ identity matrix), then
$$
\Sigma^{1/2} \begin{bmatrix} U \\  V \end{bmatrix}
$$
has variance $\Sigma$.  (It also has expected value $\begin{bmatrix} 0 \\  0 \end{bmatrix}$, and you can just add whatever vector you want as the expected value to the random vector that has the right variance and expected value $\begin{bmatrix} 0 \\  0 \end{bmatrix}$.
A sample of $200$ from this $2$-dimensional Gaussian distribution will on average have a sample mean and a sample variance equal to this given population mean and the given population variance respectively, but with probability $1$, the sample mean and sample variance will differ from those.  But with similar methods, one can get the sample mean and sample variance exactly equal to prescribed values.  The part of doing that that I haven't yet described here is how to get the sample correlation to be exactly $0$.  The way to do that is to regress the vector of $y$-values in the sample on the vector of $x$-values, then replace the $y$-values with the observed residuals.
Finding the square root of the middle matrix in $(1)$ can be done as follows: write it as
$$
\alpha\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} + \beta \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}
$$
then use the fact that these latter two matrices are symmetric and idempotent.
I don't know the matlab commands, though.
