I don't see why the uniform distribution on $[2,11]$ is denoted by $u(7,10)$, but anyway, the steps are:
- Generate a long random vector with uniform distribution on $[0,1]$: for example,
rand(1000,1)
creates a column vector of size $1000$ with this distribution. - Apply the linear transformation that maps $[0,1]$ onto $[2,11]$
- Create the histogram with some reasonable number of bins, maybe $30$.
- Plot the constant function $\dfrac{1}{11-2}$ on the interval $[2,11]$: this is the pdf.
The result should look like this:

I used Scilab instead of Matlab; the syntax is identical in the computational part and slightly different in the graphic output part.
x = (11-2)*rand(1000,1)+2*ones(1000,1) histplot(30,x) t = 2:0.01:11 f = (1/(11-2))*ones(t) plot(t,f)