Converting from a phase response to a group delay response and vice-versa
The group delay of a filter is defined as minus the change in the phase response with respect to frequency.  If the phase response of a filter is $\Phi(\omega)$, the corresponding group delay $\tau_g$ is given by:

\begin{equation}
\tau_g = -\frac{d\Phi(\omega)}{d\omega}
\end{equation}

In Matlab code, the group delay of a 4th order Butterworth filter can be calculated like so:

[b a] = butter( 4, 0.25 ); % design the filter
[Hz fVec] = freqz( b, a ); % compute the frequency response and angular frequencies
phi  = unwrap(angle(Hz)); % extract phase response
taug = -diff(unwrap(angle(Hz)))/((fVec(2))); % compute group delay
figure; plot( fVec(2:end), taug );  % plot the result


The phase response must be unwrapped to avoid $\pi$ to $-\pi$ discontinuities.  Because the difference between adjacent frequency bins is the same, we need only scale the -diff(phi) by 1/fVec(2).  Finally, because the diff command produces a vector one less than its input, the group delay values are plotted against fVec(2:end) and not fVec.

Alternatively, you could use the matlab command grpdelay, though you're likely to learn more from the previous!

figure; grpdelay(b,a);