global variables

Luis A. Montes luis.montes at qdusa.com
Mon Feb 9 10:19:11 CST 2009


I'm having a strange problem with global variables. Searched the list
but nothing seems to show up. Mind you that I'm a rather sporadic user
of octave (or Matlab, for that matter), I was just trying to import some
Matlab scripts to Octave running under Linux (Ubuntu Hardy) when I got
the following:

octave script.m
GNU Octave, version 3.0.0
Copyright (C) 2007 John W. Eaton and others.
[...]

parse error near line 3 of file p10_1.m

  syntax error

>>> global cost hr hx grid N N_2;
                                       ^

If I split the global declaration at the caret position so that I have:

global cost hr hx grid;
global N N_2;

Then the syntax error goes away. I also renamed N variables to a longer
name thinking that they could be clashing with other "default" global
variables, but no dice.

I don't understand the problem or the solution, so I'm wondering if
there is a less obvious problem with the second form that will cause the
script to fail in more subtle ways.

Thanks



More information about the Help-octave mailing list