Hi Daniel,
You can use the MATLAB builtin ichol function for Incomplete Cholesky factorization. However, if you want to optimize your implementation for performance, I suggest you to go through https://www.mathworks.com/help/matlab/matlab_prog/techniques-for-improving-performance.html. It outlines best practices while writing MATLAB code aimed at performance.
Hope this helps