[Top][All Lists]

[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 (X11/20060812)

frank wang wrote:
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");
            disp ("not one or two");

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


reply via email to

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