Can anyone help with cross correlation error in Simulink?
The edited code in your question should not result in an all-zero vector. Of course, since x contains many zeros, the autocorrelation also has many zeros, but it's non-zero in its center portion (i.e., around index $2000$).

Also note that you don't need to define a second identical vector to compute the autocorrelation. You can use the command z = xcorr(x);