If you have many (small) matrices that need to factorized in QR, instead of calling MATLAB qr in the for-loop you could use this function that can reduce by more than 6 the runtime.
According to my test MultipleQR is faster than MATLAB qr when dimension <= 10 and slower beyond that
Bruno Luong (2021). MultipleQR (https://www.mathworks.com/matlabcentral/fileexchange/68976-multipleqr), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!