How to generate random samples associated with a pdf is given by
\begin{equation} f_V(v) = \frac{1}{\pi\sqrt{v(2-v)}} \end{equation} where $v \in (0,2)$
in MATLAB. As we know in MATLAB 'randn()' is used to generate random numbers which follow a normal distribution and 'rand()' is used to generate random number associated with uniform distribution. But how to generate random samples whose associated pdf is $f_V(v)$.
You can calculate analytically in this case the cdf of your random variable (for lazy people https://www.wolframalpha.com/input/?i=integrate+1%2Fsqrt%28x*%282-x%29%29 ). Than:
$$F(x)=1-\frac{2}{\pi} \arcsin \sqrt{1-\frac{x}{2}}$$
for $0\le x\le2$
And $F^{-1}(z)=2-2 \sin^2(\frac{\pi-\pi z}{2})$ (please check my calculations)
So now take $Z\sim U(0,1)$, i.e. use your random uniform enerator. According to theory:
$$G(Z)=2-2 \sin^2\left(\frac{\pi-\pi Z}{2}\right)$$
will be distributed according to the distribution you want. See also here:
https://en.wikipedia.org/wiki/Inverse_transform_sampling