sqrt(1:4)(1:2:4) -> 1.0000 1.4142 1.7321 2.0000

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

sqrt(1:4)(1:2:4) -> 1.0000 1.4142 1.7321 2.0000

Etienne Grossmann

  Hi all,

I'm using 2.1.57. Is this the usual/desired behavior? I have the
feeling that it used to be that lines 17, 19 and 20 below would all
give the same result, that of line 20.

  Cheers,

  Etienne

octave:17> sqrt(1:4)(1:2:4)
ans =
 
  1.0000  1.4142  1.7321  2.0000
 
octave:18> 1:2:4
ans =
 
  1  3
 
octave:19> (sqrt(1:4))(1:2:4)
ans =
 
  1.0000  1.4142  1.7321  2.0000
 
octave:20> [sqrt(1:4)](1:2:4)
ans =
 
  1.0000  1.7321


PS : Please please octave don't imitate matlab's braindead behavior in
     this case

    >> sqrt(1:4)(1:2:4)
    ??? Error: () Indexing must appear last in an index expression.

    >> (sqrt(1:4))(1:2:4)
    ??? (sqrt(1:4))(1:2:4)
    |
    Error: Missing operator, comma, or semicolon.

    >> [sqrt(1:4)](1:2:4)
    ??? [sqrt(1:4)](1:2:4)
    |
    Error: Missing operator, comma, or semicolon.
 
 
--
Etienne Grossmann ------ http://www.cs.uky.edu/~etienne