To optimize MATLAB code for better performance, one can follow several approaches such as vectorization, preallocation of arrays, minimizing unnecessary calculations, and utilizing built-in functions and tools provided by MATLAB. Vectorization involves performing operations on arrays as a whole instead of using loops, which can significantly improve code efficiency. Preallocating arrays helps in avoiding unnecessary resizing during loop iterations, thus reducing computation time.