help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: slow 'eval' function - maybe pointers would do?


From: HALL, BENJAMIN PW
Subject: RE: slow 'eval' function - maybe pointers would do?
Date: Fri, 30 Oct 2009 09:31:11 -0400

>-----Original Message-----
>From: Guido Walter Pettinari [mailto:address@hidden 
>Sent: Friday, October 30, 2009 8:27 AM
>To: Octave Help Mailing List
>Subject: Re: slow 'eval' function - maybe pointers would do?
>
>


>By the way, I solved the issue by memorizing the 'ks_i' into a MxN  
>vector called 'ks' inside the loop. Once outside the loop, I filled  
>the struct in this way:
>
>for j=1:N
>   eval(  [ 's.k', int2str(j), ' = ks ( :, j );' ]     );
>endfor
>
>In this way I use more memory but the execution is faster.
>


You might try something along the lines of what follows to at least
eliminate the eval() call.  I'm not sure if use of fieldnames below is
documented in the octave manual (yet), but I'm sure there are examples
documented on the m*lab web help

flds = {};
for jj = 1:N
   flds{jj} = sprintf("k%d",jj);  ## I use sprintf() because prefer the
control
end

s.( flds{jj} ) = ks(:,jj);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]