help-octave
[Top][All Lists]
Advanced

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

Loops resource usage.


From: John W. Eaton
Subject: Loops resource usage.
Date: Fri, 22 Jun 2007 10:14:29 -0400

On 21-Jun-2007, Muthiah Annamalai wrote:

| Hello there,
| 
| I wanted to ask if there is a difference between writing a program like
| 
| for x=linspace(-pi:+pi,Npts)
|    [X,Y,Z,L,M,N]=init_variables();
|    do_a_time_consuming_long_computation();
| 
|   %clear the memory used
| 
|    clear all
| end
| 
| % and this function?
| 
| for x=linspace(-pi:+pi,Npts)
|    [X,Y,Z,L,M,N]=init_variables();
|    do_a_time_consuming_long_computation();
| end
| 
| 
| My advisor told me, it saves something and does better in long programs.
| Thanks in advance.

Doing "clear all" also clears all function definitions, so they will
have to be reloaded the next time through the loop (which will also
cause any persistent variables to be reinitialized).  In Matlab, "clear
all" also deletes debugging breakpoints.  Is that the effect you
really want?

jwe


reply via email to

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