From: Walter Roberson <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: undefined variable error message
Date: Mon, 22 Mar 2010 20:33:32 -0500
Organization: The University of Manitoba
Lines: 31
Message-ID: <ho95pd$dkr$>
References: <ho91ju$mhg$> <ho922l$t30$> <> <ho94j1$6ct$>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: 1269308014 13979 (23 Mar 2010 01:33:34 GMT)
NNTP-Posting-Date: Tue, 23 Mar 2010 01:33:34 +0000 (UTC)
User-Agent: Thunderbird (Macintosh/20100228)
In-Reply-To: <ho94j1$6ct$>
Xref: comp.soft-sys.matlab:619210

J Bell wrote:

> I made this very cumbersome by not including the other code, that which 
> defines the variables, sorry, here it is:
> beta=[1;0];
> X=[ones(N,1) rand(N,1)];
>    mu=randn(N,1);
>    Y=X*beta+mu;
> So Y is defined here.  I should have included this before, sorry.
> So the variable "Y" appears in the workspace with the value listed as 
> "<500x1 double>"

Yup, but that's in the "base workspace" that it is defined, not in the 
workspace of your function.

A variable name in your function need not have a single thing to do with 
a similar variable name in the base workspace or in the calling 
function. The content of the 'Y' variable in your function is determined 
  entirely by the _value_ of what you pass to the function in the 
corresponding argument *position*.

Just do like an earlier poster suggested, and invoke the function from 
the command window, e.g.,


That would take the _value_ of beta from the current workspace and make 
it available to the function 'dumb' under whatever name you listed first 
in the arguments in the 'function' statement.