help-octave
[Top][All Lists]
Advanced

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

Re: condition bug


From: Michael Creel
Subject: Re: condition bug
Date: Fri, 08 Sep 2006 09:24:37 +0200
User-agent: Thunderbird 1.5.0.5 (X11/20060812)



frank wang wrote:
Hi,
According to the octave maual, the if statement is considered true if its value is non-zero, and false if its value is zero. However, when I typed following command in octave 2.9.8, I got syntax error. if(1)
parse error:
      syntax error.
Thanks Frank


The problem is that you're missing "endif". Typing "help if" at the Octave prompt gives
*** if:

 -- Keyword: if (COND) ... endif
 -- Keyword: if (COND) ... else ... endif
 -- Keyword: if (COND) ... elseif (COND) ... endif
 -- Keyword: if (COND) ... elseif (COND) ... else ... endif
     Begin an if block.
          x = 1;
          if (x == 1)
            disp ("one");
          elseif (x == 2)
            disp ("two");
          else
            disp ("not one or two");
          endif

For example:
octave:6> if (1) "it works!" endif
ans = it works!

M.


reply via email to

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