There's really nothing wrong with the code; you have followed the example from the documentation for FFT and the following lines
P_amp(:,jj) = P_amp2(1:L/2+1);
P_amp(2:end-1,jj) = 2*P_amp(2:end-1,jj);
return the positive frequency half of the estimated PSD and normalized it to match total power in the double-sided PSD (P_amp2) by the factor of 2 applied to all frequencies except DC and Fmax which are not replicated in the two-sided spectrum.
The frequency vector f is for the one-sided PSD estimate.
If you really want the two-sided PSD, then don't take the positive half elements in P_amp; just use P_amp2 and the corresponding double-sided frequency vector. At that point, for convenience since apparently wouldn't need them, could rename P_amp2 to P_amp and fs to f.
BTW, the FFT and other MATLAB routines are vectorized, you can compute all the results using the original array and dispense with the for loop...
Ts = mean(diff(time));
The result will be NxM PSD (2-sided) by column same as if had used for...end loop