You can use the "rejection method" to do this very easily in MATLAB.

I assume this a school assignment, so I don't want to show you exactly how to do it. Here is the general approach:

1. Generate random x and y variables over a rectangular region that is bigger than the ellipse. You could use the MATLAB function rand() to do this.

2. Check to see whether the condition 5*x.^2+21*x.*y+25*y.^2 <= 9 is satisfied.

3. If it is satisfied, plot that point. [You could use the plot() command.] If not, "reject" that point and do not plot it.

4. Repeat until you have the desired number of points.

## Best Answer