help-octave
[Top][All Lists]
Advanced

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

RE: global variables


From: Hall, Benjamin
Subject: RE: global variables
Date: Mon, 24 May 2004 09:31:18 -0400

To get your function to recognize the global x -- as opposed to creating its own local variable x, you must first tell it so.
 
function test
global x
y = x + 1
end
 
should do what you want
-----Original Message-----
From: Dan Eriksson [mailto:address@hidden
Sent: Monday, May 24, 2004 9:10 AM
To: octave help mailing list
Subject: global variables

Hi!
 
I have version 2.1.50 and can't bring global variables into functions. This is what I get:
 
global x = 1
isglobal("x")
ans = 1

function test
isglobal("x")
y=x+1
endfunction
 
test
ans = 0
error: 'x' undefined
 
 
 
Any ideas?
 
Best regards
Dan Eriksson
 
 
___________________________________________________
Dan Eriksson
Akustikforum AB
Stampgatan 15
416 64 Gothenburg
SWEDEN
tel: +46 31 156200
fax: +46 31 150580
www.akustikforum.se

reply via email to

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