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?

回答(2 个)

bym
bym 2011-10-4
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

类别

帮助中心File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

提问:

2011-10-4

Community Treasure Hunt

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

Start Hunting!

Translated by