Is this a valid way of computing autocorrelation? I am a beginner in Digital Signal Processing and I was trying to compute and plot an autocorrelation.

I've wrote this piece of code:

r = [zeros(2,1); y(1:98,1)];
r = r.*y;


and I wished to know if this is a valid way of computing an autocorrelation.
How about xcorr(y)?  The xcorr() function is part of the Signal Processing Toolbox.