[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Vectorizing loops
From: |
Carlo de Falco |
Subject: |
Re: Vectorizing loops |
Date: |
Sat, 5 Nov 2011 20:47:00 +0100 |
On 5 Nov 2011, at 20:41, c. wrote:
>
> On 5 Nov 2011, at 07:57, andrewcd wrote:
>
>> Hi All,
>>
>
>> My code (which works) with all of the loops is:
>> G=[]
>> for j = 1:columns(N)
>> disp(j)
>> disp ('of 259')
>> for i = 1:rows(N)
>> for k = 1:size(N,3)
>> G(size(G,1)+1,4) = N(i,j,k);
>> G(size(G,1),1) = Nxy(1,j,k);
>> G(size(G,1),2) = Nxy(i,1,k);
>> G(size(G,1),3) = k;
>> end end end
>
> the following seems to work for me:
and with data of the size you mentioned I get:
>> tic, vectorized_code, toc
Elapsed time is 0.0795 seconds.
c.