Frequency estimation of circularly shifted single tone signal
The clue is that without zero-padding, the circulary shifted sequence is just a shifted version of the periodic continuation of the original sequence. That's why without zero-padding the magnitudes of the DFTs of both sequences are identical.

When you use zero-padding, the two sequences cannot be obtained from each other by pure shifting. So the DFTs must be different.

You can avoid the problem by zero-padding the circularly shifted sequence between the last and the first element of the original sequence:


% this assumes that J is in [0,N]
y2 = [z(N-J+1:N),zeros(1,N),z(1:N-J)];
Y2 = fft(y2);


This will guarantee that the magnitudes of the DFTs of the two sequences are the same, even after zero-padding.