help-octave
[Top][All Lists]
Advanced

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

Echo/Diary to record a loop exactly once


From: Martin Senator
Subject: Echo/Diary to record a loop exactly once
Date: Mon, 27 Feb 2012 13:43:55 -0500
User-agent: Mutt/1.5.20 (2009-06-14)

# file help0; ? how to echo a loop command exactly once ?
#
# The following snipet of 15 lines of code is part of an octave script,
# 'junk.m' ;

...
# new
   a0 = zeros( 1, length(del0) ) ;
   for ii = 1:length(del0) ;
       a0coef = zeros(1, length(del0) ) ;
       a0coef(1) = 3/4*h_spr                    ;
       a0coef(2) = 0                            ;
       a0coef(3) = k_spr                        ;
       a0coef(4) = -f_ampl*cos(del0(ii))                ;
       a0coef(5) = -m_mass*f_ampl^2.*sin(del0(ii)).^2 ./c_visc.^2   ;
       rts0 = roots( a0coef )   ;
       qq0 = rts0  ;
       qq0 = qq0( (imag(qq0)==0)&(real(qq0)>0) ) ;
       a0(ii) = qq0  ;
    endfor ; 
    a0sq = a0.*a0  ;
...
       
# An interactive octave session was started:
       $ octave -q
# and the first command was:
       octave:1> diary on, echo on, more off,junk
# the last two lines of the script were:
  [now] = ctime(time) #;
  diary off

# In the diary file, the first 14 lines are copied;
# all are prefixed by "+ ";
# the first (comment) line is also prefixed by an extra "#";
# this is what I hoped to see.

# Then, however, the 10 lines in the body of the loop were repeated
# 100 (or 101) times (length(del0) was 101; I didn't count).
       
# The last lines on the interactive screen were:
       + now = ctime (time)
       now = Mon Feb 27 12:01:36 2012

       + diary ('off')
       + endscript;
       octave:2> 
# while the end of the 'diary' file was:
       
       + ## ;
       + now = ctime (time)
       now = Mon Feb 27 12:01:36 2012
       
       + diary ('off')
# ? How can I get this to work properly ?
# Thanks.




reply via email to

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