help-octave
[Top][All Lists]
Advanced

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

Re: Writing scripts


From: Michael Goffioul
Subject: Re: Writing scripts
Date: Sun, 9 Dec 2007 10:26:21 +0100

On 12/8/07, James Sherman Jr. <address@hidden> wrote:
> > As you can see I have called the "plotgraph" function from within
> > "lobf". With the intent that x=data(:,1) that was defined from
> > "plotgraph".
> >
> > Once I have defined a value in one function how can it be persistant
> > in octave once the function  has ended?
>
> You can't have it persist, since all variables inside functions are
> local.

You can have persistent variables inside functions by declaring them
with the "persistent" keyword. For instance:

persistent x;

% initialize x; you can't write something like: persistent x = 10;
if (isempty(x))
  x = 1;
end

Michael.


reply via email to

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