CODE for Cross Correlation:
Check the code in the comment section.
You can refer the below documentation for understanding the use of inbuilt function....
https://in.mathworks.com/help/matlab/ref/xcorr.html
Auto Correlation in MATLAB using MATRIX Method:
https://www.youtube.com/watch?v=Svy-tXGX-sQ&t=44s