arrayfun for multiple least squares problems?

I want to solve thousands of very tiny least squares problems, all of the same size. It is taking forever to do them one at a time, but I can't seem to figure out how to use arrayfun, or accumarray, or ... to do this. Is there a way to speed this up?

Answers (2)

bym
bym on 4 Oct 2011
see if my answer on fitting multiple curves would help
arrayfun() over enough elements usually times as being slightly slower than a "for" loop that has had preallocation done.
If you are using the \ operator (mldivide), sometimes you can do better. The \ operator has to analyze what kind of problem is involved each time, but you already know the problem type.
You might, for example, be able to figure out which BLAS or LAPACK routines are suitable, and call them directly using a MATLAB File Exchange contribution http://www.mathworks.com/matlabcentral/fileexchange/16777

Categories

Asked:

on 4 Oct 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!