Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

improve loop performance

$
0
0
Hi Guys,

I look for ways to improve a loop. Simplified part of the code:

fl = cell(KK,1);
for kk = 1:KK
    fl{kk} = NaN(10);
    for ix = 1:10
        for iy = 1:10
            [~,fl{kk}(ix,iy)] = function();
        end
    end
end

Each cell of fl contains a 10x10 double array. For KK above some fifty or hundred, the loop gets very time-consuming.

The "function" is a toolbox function (not distributed with ML) which I can't modify. Anyway, I just wonder if there are some ways how to otherwise arrange the loop or split the problem in smaller portions. I looked in the docs how to programm more efficiently - parfor, vectorization, etc.. There are some examples, but I don't see what of those techniques is relevant to my problem and how I could apply it. So any hints are very appreciated. Thank you.

Viewing all articles
Browse latest Browse all 19628

Trending Articles