Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!d77g2000hsb.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Using workspace variable in m-file
Date: Sun, 7 Sep 2008 07:12:48 -0700 (PDT)
Organization: http://groups.google.com
Lines: 29
Message-ID: <51dfc6c1-996a-4a79-a957-218aca2d1ad9@d77g2000hsb.googlegroups.com>
References: <g9t86u$cu5$1@fred.mathworks.com> <g9td2h$se1$1@fred.mathworks.com> 
NNTP-Posting-Host: 75.186.70.56
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1220796768 10006 127.0.0.1 (7 Sep 2008 14:12:48 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 7 Sep 2008 14:12:48 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: d77g2000hsb.googlegroups.com; posting-host=75.186.70.56; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 
Xref: news.mathworks.com comp.soft-sys.matlab:489028



On Sep 6, 4:51=A0am, "John D'Errico" <woodch...@rochester.rr.com> wrote:
> "Husam Aldahiyat" <numand...@gmail.com> wrote in message <g9td2h$se...@fr=
ed.mathworks.com>...
> > Use global. Solves all life's problems.
>
> Yes, and it creates other problems. Globals
> are sloppy, lazy programming.
>
> Pass the variables in. If they are functions,
> perhaps anonymous functions, or simply
> variables, then it is far simpler to pass them
> in as arguments to the function. This solves
> the OP's problems without creating other
> ones.
>
> John

-------------------------------------------
John:
What if the function is the callback of a button (placed with GUIDE)?
How do you pass variables into that?  GUIDE automatically puts in 3
arguments.  How can you get in other variables that may be needed
inside that function?  I've just been using "global" because I don't
know any other way to get stuff in there.  For a simple example, let's
say the button should multiply a vector by 2 and plot in in an axes.
How do you get that vector into the callback function of the button?
Thanks,
ImageAnalyst
-----------------------------------------------------------