The essential bandwidth of a rectangular pulse The problem is to estimate the essential bandwidth of a rectangular pulse 

\begin{equation}
g(t) = \Pi(t/T),
\end{equation}

Where the essential bandwidth must contain at least $90\%$ of the pulse energy.

Here's what I'm trying to solve : 

$$0.9 =\frac1\pi\int\limits_0^{2BT\pi} \mathrm{sinc}^2 \left(\frac x2\right) \,dx$$

I'm not sure how to get MATLAB to solve this numerically for the upper bound value. 

first the energy for the pulse is $E_g$ 

\begin{equation}
E_g = \int^{+\infty}_{-\infty} g^2(t)dt\, = \int^{+T/2}_{-T/2} dt\, = T
\end{equation}

and 

\begin{equation}
\ \Pi(t/T) \Longleftrightarrow T\mathrm{sinc}(\pi fT)
\end{equation}

and for the Energy Spectral Density of the pulse

\begin{equation} 
\ \Psi(f) = \mid G(f) \mid ^2 = T^2\mathrm{sinc}^2(\pi fT)
\end{equation}

The energy $E_B$ within the band from $0$ to $B$ hertz is 

\begin{equation} 
\ E_B = \int^{+B}_{-B} T^2 \mathrm{sinc}^2(\pi ft)df\,
\end{equation} 

setting 

\begin{equation} 
\ 2 \pi fT = x 
\end{equation}

\begin{equation} 
\ df = dx/((2 \pi fT)  
\end{equation}
plugging into the integral
\begin{equation}
\  E_B = (T/ \pi)  \int_{0}^{2 \pi BT} \mathrm{sinc}^2(x/2)dx\,
\end{equation}
\begin{equation}
\ E_g = T 
\end{equation}

\begin{equation}
\ 0.9 = (E_b/E_g) =  1/ \pi \int^{2 \pi BT}_{0} \mathrm{sinc}^2(x/2)dx\, 
\end{equation}

I wanted to work through this example fully, but I'm not sure how to get this numerically solved, solving for the bandwidth B from the upper bound of the integral using MATLAB.
First note that $$\mathcal{F}\{\mathrm{rect}(\frac{t}{T})\}=T\mathrm{sinc}(Tf)=\frac{\sin(\pi Tf)}{\pi f}$$ 
Then you have correctly calculated the pulse energy as $$E_g=\int_{-\infty}^{+\infty}g^2(t)dt=T$$
Now we want to find $B$ such that
$$\int_{-B}^{B}T^2\mathrm{sinc}^2(Tf)df=0.9T$$
or since the function is even,
$$\int_{0}^{B}T\mathrm{sinc}^2(Tf)df=0.45$$ which by assuming $$Tf=x\Rightarrow df=dx/T$$ is 
$$\int_{0}^{TB}\mathrm{sinc}^2(x)dx=0.45$$
Using the following code we get the essential bandwidth $$\bbox[0.5em,#efe,border:0.1em groove navy]{\
B\approx\frac{0.8455}{T}\
}$$

J = 0.45; %target value
acceptable_error = 1e-4;
dx = 1e-5;
xmax = 1; %initial guess
max_iterations = 100;
iteration = 0;
while iteration &lt; max_iterations;
    x = 0:dx:xmax;
    y=sinc(x).^2;
    I = trapz(x,y);
    if abs(I-J) &lt;= acceptable_error
        break;
    end
    if I &lt; J
        xmax = 3/2*xmax;
    else
        xmax = xmax/2;
    end
    iteration = iteration+1;
end
fprintf('absolute error = %f\n',abs(I-J));
fprintf('solution = %f\n',xmax)