Welch’s Algorithm of Averaging Modified Periodograms
Understanding the Windowing Method in PSD Calculation

Please go through the link .. Someone has posted their code snippet which matches with MATLAB output. Hope that might give you better understanding