Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Input variable from workspace within a function
Date: Thu, 20 Sep 2007 18:33:47 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <fcueeb$jnj$1@fred.mathworks.com>
References: <fcucjg$k1q$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-06-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1190313227 20211 172.30.248.36 (20 Sep 2007 18:33:47 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 20 Sep 2007 18:33:47 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 791003
Xref: news.mathworks.com comp.soft-sys.matlab:429482



"First Last" <nospam@nospamplease.com> wrote in message 
<fcucjg$k1q$1@fred.mathworks.com>...
> I have a variable, var2, in my desktop workspace, which I
> can manipulate, declare, and save just fine. 
> 
> However, I have a function that utilizes the 'input' 
command
> that asks, for instance:
> 
> function data = myfn
>      variable1 = input('please input variable1: ');
>      if isempty(variable1)
>          do some task here
>      end
>      
>      data = somecalc(variable1)
> end
> 
> However I want to assign 'var2' to 'variable1' within the
> function call. Without making it an input to the 
function (I
> sort of just answered my question), is there a way of
> addressing the variable workspace outside of the 
function's
> workspace? 
> 
> Thanks ... 

your 'desktop workspace' is commonly called the 'base' 
workspace.  each function (not script) gets its own 
workspace.  functions can access the base workspace using 
the evalin and assignin commands, take a look at them in 
the help for syntax.