help-octave
[Top][All Lists]
Advanced

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

Re: unexpected syntax error when defining a global variable?


From: Julien Bect
Subject: Re: unexpected syntax error when defining a global variable?
Date: Tue, 21 Apr 2015 18:51:37 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

Le 21/04/2015 18:43, Nicholas Jankowski a écrit :
simple example:

-------------------
>> segments = 5;
>> p_i(1:segments+1)= 0
p_i =

   0   0   0   0   0   0

BUT

>> segments = 5;
>> global p_i(1:segments+1)= 0
parse error:
  syntax error
>>> global p_i(1:segments+1)= 0
                             ^
-----------------------------------
if the characters spacing is messed up, it's pointing to the (

Is that supposed to happen? I didn't think a global designation was supposed to change anything with syntax. bug?

Nick J.

I don't think you can declare a global and use indexing on it at the same time. Try in two steps:

global p_i
p_i(1:segments+1)= 0;

or

global p_i
p_i = zeros (1, segments + 1);

https://www.gnu.org/software/octave/doc/interpreter/Global-Variables.html#Global-Variables


reply via email to

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