Code Comments
Programming Forum and web based access to our favorite programming groups.Matlab globals are normally accessible from the command line and all functio ns. Is it possible to stay in the interactive environment (ie, m files), but restrict the scope of globals to the functions within a file, so they are no t accessible from the base workspace? thanks ross
Post Follow-up to this messageross wrote: > > > Matlab globals are normally accessible from the command line and > all functions. > > Is it possible to stay in the interactive environment (ie, m > files), but > restrict the scope of globals to the functions within a file, so > they are not > accessible from the base workspace? > > thanks > > ross No but, nested function "share" by reference the variables defined in the outer function. See "Scott and Doug's Pick of the W", <http://www.mathworks .com/matlabcentral/pick/> / per
Post Follow-up to this message"Is it possible to stay in the interactive environment (ie, m files), but restrict the scope of globals to the functions within a file, so they are not accessible from the base workspace? " Try declaring the variables 'persistent' in the file with the functions. Bob
Post Follow-up to this message"metiche" <ayduda@usa.com> wrote: >Try declaring the variables 'persistent' in the file with the >functions. > >Bob Should that work in R13? I can't seem to get it to work ... maybe I'm just dim. Documentation doesn't mention that use of 'persistent' as far as I can see. ross
Post Follow-up to this messageIn article <d7fstu$7r2$1@arachne.labyrinth.net.au>, ross@nospam.com says... > "metiche" <ayduda@usa.com> wrote: > > > Should that work in R13? I can't seem to get it to work ... maybe I'm jus t > dim. Documentation doesn't mention that use of 'persistent' as far as I c an > see. > > ross > > > persistent is a part of the R13 language. It's scope is on a function basis -- not by file. --Loren
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.