help-octave
[Top][All Lists]
Advanced

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

Re: Problem with an if statement inside a while loop


From: SikoraP13
Subject: Re: Problem with an if statement inside a while loop
Date: Thu, 1 Aug 2013 07:29:56 -0700 (PDT)

Thanks for the response, James.  I just tried that and I am still getting the
same error.  I've also tried putting the if statements in a for loop, but
get another problem.  It gives me:

syntax error

>>>  angle(i+1)=angle(i)
               ^

however if I comment out all of the pos items, it runs fine.  This leads me
to believe there may be something with my indexing, but I'm not completely
sure what it is.  Either the for or the while will work for what I need it
to, so any help fixing either solution would be appreciated.


I essentially tried replacing the while loop with this statement:
for i=1:length(commandList)

                if commandList(1,i)=="+"
                        pos(i+1,:)=pos(i,:)+[0,0,90]
                        angle(i+1)=angle(i)+angleInc
                        
                elseif commandList(1,i)=="-"
                        pos(i+1,:)=pos(i,:)+[0,0,90]
                        angle(i+1)=angle(i)-angleInc
                        
                elseif commandList(1,i)=="F"
                        
pos(i+1,:)=pos(i,:)+1./scalingFactor.^n.*[cos([pos(i,3),sin([pos(i,3),0]
                        angle(i+1)=angle(i)
                        
                else 
                        pos(i+1,:)=pos(i,:)
                        angle(i+1)=angle(i)
                                        
                end



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Problem-with-an-if-statement-inside-a-while-loop-tp4656310p4656315.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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