<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504</link>
    <title>MATLAB Central Newsreader - Nested functions and oop</title>
    <description>Feed for thread: Nested functions and oop</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 24 Feb 2006 03:18:06 -0500</pubDate>
      <title>Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296668</link>
      <author>Philippe Maincon</author>
      <description>Having used Matlab's object oriented programming for a while, I am&lt;br&gt;
quite confused by the recent introduction of nested functions and&lt;br&gt;
their combination with function handles.&lt;br&gt;
&lt;br&gt;
The following code shows how nested functions, structures and&lt;br&gt;
handles are used to create... a new syntax for oop in Mat lab.&lt;br&gt;
&lt;br&gt;
function obj = MyClass(input)&lt;br&gt;
x = input;&lt;br&gt;
y = 3.14159;&lt;br&gt;
% obj = ParentClass(input/2);&lt;br&gt;
obj.increment = @increment;&lt;br&gt;
obj.set = @set;&lt;br&gt;
obj.display = @display;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function increment&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x = x+1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function set(in)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y = in;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function display&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Using the class remind furiously of C++&lt;br&gt;
c = MyClass(27);&lt;br&gt;
c.display()&lt;br&gt;
c.increment()&lt;br&gt;
c.set(2.71)&lt;br&gt;
c.display()&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
This gives MATLAB the questionable privilege of being the 1st&lt;br&gt;
programming language with 2 competing oop syntaxes! Using this&lt;br&gt;
syntax, one looses quite a few MATLAB features, including, as far as&lt;br&gt;
I can see, the ability to overload operators, MATLABS's automated&lt;br&gt;
calls to &quot;display(o)&quot; (it won't call o.display(), for sure). It seems&lt;br&gt;
to me that anything that can be done with nested funs and handles can&lt;br&gt;
be done with standard matlab objects, and that we have a case of&lt;br&gt;
language cluttering.&lt;br&gt;
&lt;br&gt;
So my questions to all wise guys:&lt;br&gt;
- What did I miss? What can be done with nested funs that can't be&lt;br&gt;
done with objects? Maybe there are efficiency issues? Or was it a&lt;br&gt;
bid to make basic oop functionality available to users that shy&lt;br&gt;
away/are unfamiliar with oop?&lt;br&gt;
&lt;br&gt;
- Was it MathWorks intention to provide an alternative oop syntax, or&lt;br&gt;
am I victim of my own creativity? Is this related to MathWorks call&lt;br&gt;
for beta users for some new form of oop, a few months ago?&lt;br&gt;
&lt;br&gt;
- Can we rely on the present oop syntax to be maintained in the&lt;br&gt;
future? What are the plans?&lt;br&gt;
&lt;br&gt;
I look forward to your comments&lt;br&gt;
&lt;br&gt;
Philippe&lt;br&gt;
&lt;br&gt;
P.S. To get in touch, check out www.safran.co.za. Sorry for the&lt;br&gt;
hassle, but I do not enjoy spam!</description>
    </item>
    <item>
      <pubDate>Fri, 24 Feb 2006 01:07:44 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296671</link>
      <author>David Mackenzie</author>
      <description>&lt;br&gt;
Philippe Maincon schrieb:&lt;br&gt;
&lt;br&gt;
&amp;lt;snip&amp;gt; wonderfully clear insight... &amp;lt;snip&amp;gt;&lt;br&gt;
&lt;br&gt;
Philippe,&lt;br&gt;
although I can't answer your questions I'd like to thank you for&lt;br&gt;
posting this - I haven't been very active in MATLAB recently and it&lt;br&gt;
wasn't at all clear to me from the descriptions of nested functions&lt;br&gt;
floating around that this is possible.  A couple of years ago I&lt;br&gt;
struggled bravely with MATLAB objects (in an attempt to build a graphic&lt;br&gt;
user object toolbox, a central aim of which was to implement something&lt;br&gt;
similar to what in Version 7 appeared as uipanel objects) but wasn't&lt;br&gt;
really happy with the results, the main problem being that assignment&lt;br&gt;
of the object was necessary if attributes were to be updated - very&lt;br&gt;
ugly.  In order to avoid using global variables I had to use existing&lt;br&gt;
graphic objects to store attributes.  In contrast, your solution allows&lt;br&gt;
proper instantiation of objects!&lt;br&gt;
&lt;br&gt;
For example, if you change the increment function to allow a couple of&lt;br&gt;
dummy parameters:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function increment(obj,event)&lt;br&gt;
and define a pushbutton from the command line:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;uicontrol('style','pushbutton','callback',c.increment)&lt;br&gt;
this works fine when you click the button.  However, I never found a&lt;br&gt;
good way to do this with MATLAB objects without using global variables&lt;br&gt;
(admittedly I wasn't familiar with function handles at that time).&lt;br&gt;
&lt;br&gt;
Maybe someone else knew this already, but I've never seen it explained.&lt;br&gt;
&amp;nbsp;Somehow this important feature wasn't highlighted in the release&lt;br&gt;
notes.  I think your insight is certainly worthy of the File Exchange.&lt;br&gt;
&lt;br&gt;
Best regards,&lt;br&gt;
David Mackenzie</description>
    </item>
    <item>
      <pubDate>Fri, 24 Feb 2006 10:57:12 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296681</link>
      <author>Michael Wild</author>
      <description>using function handles in this way seems to be a very convenient idea. &lt;br&gt;
and i don't think that it is cluttering the language, since this &lt;br&gt;
methodology doesn't really define methods, but rather registers them as &lt;br&gt;
data fields which happen to be function handles and thus are executable. &lt;br&gt;
it is more similar to registering callbacks in some gui-toolkit, or more &lt;br&gt;
general, in some well-known design-patterns.&lt;br&gt;
&lt;br&gt;
as these function handles are not really methods, it is clear that they &lt;br&gt;
won't be called by matlab (how should it know about them being actually &lt;br&gt;
methods?).&lt;br&gt;
&lt;br&gt;
what comes to mind, is using the conventional way of oop in matlab, but &lt;br&gt;
then register the methods in the way you showed. this enables you to get &lt;br&gt;
both: overloading and this convenient way of calling the callback. &lt;br&gt;
however, i'm not sure what this means with respect to polymorphism (does &lt;br&gt;
matlab support that?). it will probably fail utterly...&lt;br&gt;
&lt;br&gt;
to be honest, i rarely ever use the oop feature offered by matlab. i &lt;br&gt;
just think it is too clumsy. tmw really should think about redoing the &lt;br&gt;
whole thing. for one: define a whole class in one file. and then &lt;br&gt;
handling member access is another thing which makes oop in matlab a real &lt;br&gt;
pain. it is just plain, that the oo feature whas plugged on top of a &lt;br&gt;
procedural language.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
michael</description>
    </item>
    <item>
      <pubDate>Fri, 24 Feb 2006 05:05:33 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296683</link>
      <author>Brad Phelan</author>
      <description>David Mackenzie wrote:&lt;br&gt;
&amp;gt; Philippe Maincon schrieb:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;lt;snip&amp;gt; wonderfully clear insight... &amp;lt;snip&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Philippe,&lt;br&gt;
&amp;gt; although I can't answer your questions I'd like to thank you for&lt;br&gt;
&amp;gt; posting this - I haven't been very active in MATLAB recently and it&lt;br&gt;
&amp;gt; wasn't at all clear to me from the descriptions of nested functions&lt;br&gt;
&amp;gt; floating around that this is possible.  A couple of years ago I&lt;br&gt;
&amp;gt; struggled bravely with MATLAB objects (in an attempt to build a graphic&lt;br&gt;
&amp;gt; user object toolbox, a central aim of which was to implement something&lt;br&gt;
&amp;gt; similar to what in Version 7 appeared as uipanel objects) but wasn't&lt;br&gt;
&amp;gt; really happy with the results, the main problem being that assignment&lt;br&gt;
&amp;gt; of the object was necessary if attributes were to be updated - very&lt;br&gt;
&amp;gt; ugly.  In order to avoid using global variables I had to use existing&lt;br&gt;
&amp;gt; graphic objects to store attributes.  In contrast, your solution allows&lt;br&gt;
&amp;gt; proper instantiation of objects!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; For example, if you change the increment function to allow a couple of&lt;br&gt;
&amp;gt; dummy parameters:&lt;br&gt;
&amp;gt;     function increment(obj,event)&lt;br&gt;
&amp;gt; and define a pushbutton from the command line:&lt;br&gt;
&amp;gt;     uicontrol('style','pushbutton','callback',c.increment)&lt;br&gt;
&amp;gt; this works fine when you click the button.  However, I never found a&lt;br&gt;
&amp;gt; good way to do this with MATLAB objects without using global variables&lt;br&gt;
&amp;gt; (admittedly I wasn't familiar with function handles at that time).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Maybe someone else knew this already, but I've never seen it explained.&lt;br&gt;
&amp;gt;  Somehow this important feature wasn't highlighted in the release&lt;br&gt;
&amp;gt; notes.  I think your insight is certainly worthy of the File Exchange.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Best regards,&lt;br&gt;
&amp;gt; David Mackenzie&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
I've been using the above techniques for object oriented programming in &lt;br&gt;
Matlab for a while now. See the below snippets on my website for some &lt;br&gt;
tutorials.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://xtargets.com/snippets/posts/show/39&quot;&gt;http://xtargets.com/snippets/posts/show/39&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://xtargets.com/snippets/posts/show/42&quot;&gt;http://xtargets.com/snippets/posts/show/42&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Nested functions can be used to build object oriented frameworks but &lt;br&gt;
that is merely a side effect. They are usefull in their own right. If &lt;br&gt;
you want to get technical then yes objects and nested functions are&lt;br&gt;
dual concepts.&lt;br&gt;
&lt;br&gt;
An object is data with a set of nested functions attached.&lt;br&gt;
A nested function is a function with some data attached.&lt;br&gt;
&lt;br&gt;
Mathworks could build a proper OO framework around nested functions I &lt;br&gt;
guess but I don't believe they will.&lt;br&gt;
&lt;br&gt;
Brad</description>
    </item>
    <item>
      <pubDate>Fri, 24 Feb 2006 06:48:30 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296700</link>
      <author>Philippe Maincon</author>
      <description>David, Michael, Brad,&lt;br&gt;
&lt;br&gt;
Thank you for your answers, I definitely learned something&lt;br&gt;
interesting today. I will try to summarise what I learned from your&lt;br&gt;
contributions:&lt;br&gt;
&lt;br&gt;
- A strong anti-bug feature of Matlab is that a function can only&lt;br&gt;
modify a variable if the variable appears on the left hand side of&lt;br&gt;
the function call. This is thanks to MATLAB's pass by value&lt;br&gt;
[apparent] behaviour. This makes it difficult to have different part&lt;br&gt;
of a software work on the same database (in C++ and the like, objects&lt;br&gt;
would have received a POINTER to the database, and used it to access&lt;br&gt;
the data).&lt;br&gt;
&lt;br&gt;
Wether one makes them object-like or not, nest&amp;handle allows to pass&lt;br&gt;
to a function THE RIGHT TO DO A SPECIFIC OPERATION on a set of data.&lt;br&gt;
This breaks the above anti-bug rule, but in a very elegant manner:&lt;br&gt;
IfUserWants(a.makeItGreen);&lt;br&gt;
The function IfUserWants can modify the data in &quot;a&quot; but only in one&lt;br&gt;
way: &quot;makeItGreen&quot; It can't make it red or erase it...&lt;br&gt;
&lt;br&gt;
A significant advantage over pointers is that &quot;the last one out&lt;br&gt;
switches off the light&quot;, or at least, I strongly suspect so. Once the&lt;br&gt;
function handles are generated they &quot;point&quot; to the data, and you can&lt;br&gt;
copy these handles (this acts as &quot;shallow copy&quot;). In C++ et al., if&lt;br&gt;
you delete all your pointers, you have a memory leak. Here... you can&lt;br&gt;
distribute &quot;pointers&quot; around, and yet do not need to bother about a&lt;br&gt;
destructor.&lt;br&gt;
&lt;br&gt;
- One can &quot;hack&quot; nested functiosn &amp; handles to create hack-object,&lt;br&gt;
but note the unusual (hence risky) features:&lt;br&gt;
a = b is a shallow copy for hack-objects, and a deep copy for&lt;br&gt;
standard objects... For hack-objects, function argument passage is by&lt;br&gt;
reference, for standard objects, it's by value. If you pass a&lt;br&gt;
hack-object to a function, you basicaly pass the rights to do all&lt;br&gt;
permissible operations.&lt;br&gt;
&lt;br&gt;
I certainly retract the comment that nest&amp;handle provides nothing&lt;br&gt;
new. As for hack-objects, I reckon a) there is a market for them b)&lt;br&gt;
be very, very cautious!&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
&lt;br&gt;
Philippe</description>
    </item>
    <item>
      <pubDate>Fri, 24 Feb 2006 09:57:39 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296744</link>
      <author>Peter Boettcher</author>
      <description>&quot;Philippe Maincon&quot; &amp;lt;bogus@see.below.co.za&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt; This gives MATLAB the questionable privilege of being the 1st&lt;br&gt;
&amp;gt; programming language with 2 competing oop syntaxes! Using this&lt;br&gt;
&amp;gt; syntax, one looses quite a few MATLAB features, including, as far as&lt;br&gt;
&amp;gt; I can see, the ability to overload operators, MATLABS's automated&lt;br&gt;
&amp;gt; calls to &quot;display(o)&quot; (it won't call o.display(), for sure).&lt;br&gt;
&lt;br&gt;
I haven't really tried it myself, but take a look at the code for&lt;br&gt;
the memmapfile class in a recent MATLAB.  It seems to be using a new&lt;br&gt;
class syntax that uses the nested function tricks you describe, but&lt;br&gt;
also has real overloaded display routines and such.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Peter Boettcher &amp;lt;boettcher@ll.mit.edu&amp;gt;&lt;br&gt;
MIT Lincoln Laboratory&lt;br&gt;
MATLAB FAQ: &lt;a href=&quot;http://www.mit.edu/~pwb/cssm/&quot;&gt;http://www.mit.edu/~pwb/cssm/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 24 Feb 2006 12:35:40 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296813</link>
      <author>Brad Phelan</author>
      <description>Peter Boettcher wrote:&lt;br&gt;
&amp;gt; &quot;Philippe Maincon&quot; &amp;lt;bogus@see.below.co.za&amp;gt; writes:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt; This gives MATLAB the questionable privilege of being the 1st&lt;br&gt;
&amp;gt;&amp;gt; programming language with 2 competing oop syntaxes! Using this&lt;br&gt;
&amp;gt;&amp;gt; syntax, one looses quite a few MATLAB features, including, as far as&lt;br&gt;
&amp;gt;&amp;gt; I can see, the ability to overload operators, MATLABS's automated&lt;br&gt;
&amp;gt;&amp;gt; calls to &quot;display(o)&quot; (it won't call o.display(), for sure).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I haven't really tried it myself, but take a look at the code for&lt;br&gt;
&amp;gt; the memmapfile class in a recent MATLAB.  It seems to be using a new&lt;br&gt;
&amp;gt; class syntax that uses the nested function tricks you describe, but&lt;br&gt;
&amp;gt; also has real overloaded display routines and such.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
I think it was an accident for that file to not be p-coded. It looks &lt;br&gt;
like a new unsupported API. I wouldn't garuntee that the API will stay &lt;br&gt;
the same in future releases. It looks interesting though.&lt;br&gt;
&lt;br&gt;
B&lt;br&gt;
&lt;br&gt;
--&lt;br&gt;
&lt;a href=&quot;http://xtargets.com&quot;&gt;http://xtargets.com&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Sun, 26 Feb 2006 03:32:10 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#296999</link>
      <author>Philippe Maincon</author>
      <description>Peter,&lt;br&gt;
&lt;br&gt;
That was an interesting peep in the code, and answers more of my&lt;br&gt;
inital questions about the future of oo in MATLAB. I bet this is the&lt;br&gt;
syntax that was released for beta testing last year. (I was on a&lt;br&gt;
dial-up line in the bush in Germany and couldn't join the feast)&lt;br&gt;
&lt;br&gt;
Mike's call for &quot;all methods in one file&quot; is about to be heeded -&lt;br&gt;
except for the comments that have to be in their own file (hey&lt;br&gt;
MathWorks, if you start a job, do it completely! Put comments into&lt;br&gt;
the main file, and reprogram &quot;help&quot; - OK' I'm sure you plan to do&lt;br&gt;
this actually)&lt;br&gt;
&lt;br&gt;
And there is a destructor now, of course, necessary for memmapfile to&lt;br&gt;
properly close down a file access. But lack of call to destructor&lt;br&gt;
does not seem to imply memory leak. You know what, I have some deep&lt;br&gt;
respect those guys.&lt;br&gt;
&lt;br&gt;
Good news of the day: this looks backward compatible with present day&lt;br&gt;
syntax (well anything else would have been a serious surprise). I&lt;br&gt;
don't need to send my 10.000 lines of code to the bin... Dear&lt;br&gt;
MathWorks, with the next release, give us a utility that packs old&lt;br&gt;
method-files into one new-syntax file, pretty please.&lt;br&gt;
&lt;br&gt;
Cheers&lt;br&gt;
&lt;br&gt;
Philippe</description>
    </item>
    <item>
      <pubDate>Wed, 01 Mar 2006 00:14:17 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#297617</link>
      <author>David Mackenzie</author>
      <description>If anyone from The Mathworks is following this thread - I'd love to see&lt;br&gt;
a white paper on this subject.  There's obviously much more already&lt;br&gt;
implemented in MATLAB than is currently documented.&lt;br&gt;
&lt;br&gt;
David</description>
    </item>
    <item>
      <pubDate>Thu, 23 Mar 2006 12:31:22 -0500</pubDate>
      <title>Re: Nested functions and oop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/117504#303007</link>
      <author>Raymond Norris</author>
      <description>Brad-&lt;br&gt;
&lt;br&gt;
A very large part of OOP is inheritance. Without a true class&lt;br&gt;
object, how do you subclass your data structures?&lt;br&gt;
&lt;br&gt;
Raymond&lt;br&gt;
&lt;br&gt;
Brad Phelan wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; David Mackenzie wrote:&lt;br&gt;
&amp;gt;&amp;gt; Philippe Maincon schrieb:&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; &amp;lt;snip&amp;gt; wonderfully clear insight... &amp;lt;snip&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Philippe,&lt;br&gt;
&amp;gt;&amp;gt; although I can't answer your questions I'd like to thank you&lt;br&gt;
for&lt;br&gt;
&amp;gt;&amp;gt; posting this - I haven't been very active in MATLAB recently&lt;br&gt;
and&lt;br&gt;
&amp;gt; it&lt;br&gt;
&amp;gt;&amp;gt; wasn't at all clear to me from the descriptions of nested&lt;br&gt;
&amp;gt; functions&lt;br&gt;
&amp;gt;&amp;gt; floating around that this is possible. A couple of years ago I&lt;br&gt;
&amp;gt;&amp;gt; struggled bravely with MATLAB objects (in an attempt to build a&lt;br&gt;
&amp;gt; graphic&lt;br&gt;
&amp;gt;&amp;gt; user object toolbox, a central aim of which was to implement&lt;br&gt;
&amp;gt; something&lt;br&gt;
&amp;gt;&amp;gt; similar to what in Version 7 appeared as uipanel objects) but&lt;br&gt;
&amp;gt; wasn't&lt;br&gt;
&amp;gt;&amp;gt; really happy with the results, the main problem being that&lt;br&gt;
&amp;gt; assignment&lt;br&gt;
&amp;gt;&amp;gt; of the object was necessary if attributes were to be updated -&lt;br&gt;
&amp;gt; very&lt;br&gt;
&amp;gt;&amp;gt; ugly. In order to avoid using global variables I had to use&lt;br&gt;
&amp;gt; existing&lt;br&gt;
&amp;gt;&amp;gt; graphic objects to store attributes. In contrast, your&lt;br&gt;
solution&lt;br&gt;
&amp;gt; allows&lt;br&gt;
&amp;gt;&amp;gt; proper instantiation of objects!&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; For example, if you change the increment function to allow a&lt;br&gt;
&amp;gt; couple of&lt;br&gt;
&amp;gt;&amp;gt; dummy parameters:&lt;br&gt;
&amp;gt;&amp;gt; function increment(obj,event)&lt;br&gt;
&amp;gt;&amp;gt; and define a pushbutton from the command line:&lt;br&gt;
&amp;gt;&amp;gt; uicontrol('style','pushbutton','callback',c.increment)&lt;br&gt;
&amp;gt;&amp;gt; this works fine when you click the button. However, I never&lt;br&gt;
&amp;gt; found a&lt;br&gt;
&amp;gt;&amp;gt; good way to do this with MATLAB objects without using global&lt;br&gt;
&amp;gt; variables&lt;br&gt;
&amp;gt;&amp;gt; (admittedly I wasn't familiar with function handles at that&lt;br&gt;
&amp;gt; time).&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Maybe someone else knew this already, but I've never seen it&lt;br&gt;
&amp;gt; explained.&lt;br&gt;
&amp;gt;&amp;gt; Somehow this important feature wasn't highlighted in the&lt;br&gt;
release&lt;br&gt;
&amp;gt;&amp;gt; notes. I think your insight is certainly worthy of the File&lt;br&gt;
&amp;gt; Exchange.&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Best regards,&lt;br&gt;
&amp;gt;&amp;gt; David Mackenzie&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I've been using the above techniques for object oriented&lt;br&gt;
&amp;gt; programming in&lt;br&gt;
&amp;gt; Matlab for a while now. See the below snippets on my website for&lt;br&gt;
&amp;gt; some&lt;br&gt;
&amp;gt; tutorials.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;http://xtargets.com/snippets/posts/show/39&quot;&gt;http://xtargets.com/snippets/posts/show/39&lt;/a&gt;&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;http://xtargets.com/snippets/posts/show/42&quot;&gt;http://xtargets.com/snippets/posts/show/42&lt;/a&gt;&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Nested functions can be used to build object oriented frameworks&lt;br&gt;
&amp;gt; but&lt;br&gt;
&amp;gt; that is merely a side effect. They are usefull in their own right.&lt;br&gt;
&amp;gt; If&lt;br&gt;
&amp;gt; you want to get technical then yes objects and nested functions are&lt;br&gt;
&amp;gt; dual concepts.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; An object is data with a set of nested functions attached.&lt;br&gt;
&amp;gt; A nested function is a function with some data attached.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Mathworks could build a proper OO framework around nested functions&lt;br&gt;
&amp;gt; I&lt;br&gt;
&amp;gt; guess but I don't believe they will.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Brad&lt;br&gt;
&amp;gt;</description>
    </item>
  </channel>
</rss>

