[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Getting 'for' loop to print only once using echo/diary
From: |
Martin Senator |
Subject: |
Getting 'for' loop to print only once using echo/diary |
Date: |
Thu, 1 Mar 2012 11:07:21 -0500 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Help: getting 'for' loop to print only once using echo/diary
I am using a 'for' loop in a script (because I can't
get 'roots' to work on a vector).
I start an interactive Octave session with:
$ octave -q
Then I issue the command (junk.m is the name of the script file):
octave:1> diary on, echo on, more off,junk
The last two lines of the script are:
[now] = ctime(time) #;
diary off
After the script runs Octave is ready for more interactive commands.
But, the 'for' loop is in the 'diary' file 101 times.
What can I do to get the desired behavior?
Here is the 'for' loop code I am using:
...
# 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 ;
...
Thanks,
Martin
- Getting 'for' loop to print only once using echo/diary,
Martin Senator <=