help-octave
[Top][All Lists]

## RE: problem with column specification in matrices

 From: Julian DeMarchi Subject: RE: problem with column specification in matrices Date: Thu, 31 Oct 2002 14:33:01 -0500

```And on that note, Matlab yields

>> [ linspace (1, 2) ]
??? [ linspace (1, 2) ]
|
Error: ")" expected, "," found.

It does not like the space between function name linspace and argument list (1,
2).

However,

[n (1+1./n).^n]

and

[n, (1+1./n).^n]

both yield identical results (space treated as comma).  Because, in Matlab (as
in Octave),

>> n, (1+1./n).^n

n =

10
100
500
1000
5000
10000

ans =

2.5937
2.7048
2.7156
2.7169
2.7180
2.7181

So now I'm confused about what you mean about "indexing"...  If that was the
reason it works in Matlab but not in Octave, why do they work the same way
without brackets?

- Julian

-----Original Message-----

Inside the square brackets that delimit a matrix expression, Octave
looks at the surrounding context to determine whether spaces and newline
characters should be converted into element and row separators, or
simply ignored, so commands like

[ linspace (1, 2) ]

will work.

IMHO, it was bad design for Matlab to make whitespace magic inside the
square brackets.

jwe

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

```