[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to handle slow array loops?
From: |
otrov |
Subject: |
Re: How to handle slow array loops? |
Date: |
Thu, 02 Jun 2011 07:02:41 +0200 |
Thanks for the tip
That speeds up just fine :)
On Thu, 02 Jun 2011 04:56:40 +0200 "James Sherman Jr."
<address@hidden> wrote:
>
>As to why, the short answer is that your comparing compiled code
>to a
>script. I'm not an expert on this, so someone more knowledgeable
>that me
>can explain in more detail.
>
>As to how to speed up this code, you could do something like:
>function h = loop(range)
>
>xx = rand(2, range);
>
>t = round(xx(:) * 1000 + 1);
>h = histc(t, 1:1001);
>
>endfunction
>
>I think will do the same thing that your function does.
>
>Hope this helps.