Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
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$1@canopus.cc.umanitoba.ca>
References: <ho91ju$mhg$1@fred.mathworks.com> <ho922l$t30$1@fred.mathworks.com> <cd8c0f96-ec6b-47bc-8c0c-2d8b4dd441cb@d30g2000prn.googlegroups.com> <ho94j1$6ct$1@fred.mathworks.com>
NNTP-Posting-Host: ssh.ibd.nrc.ca
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: canopus.cc.umanitoba.ca 1269308014 13979 132.246.132.10 (23 Mar 2010 01:33:34 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Tue, 23 Mar 2010 01:33:34 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228)
In-Reply-To: <ho94j1$6ct$1@fred.mathworks.com>
Xref: news.mathworks.com 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.,

dumb(beta,Y,X)

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.