Thread Subject: Reason Matlab has never implemented incrementation operators?

Subject: Reason Matlab has never implemented incrementation operators?

From: klydefrog

Date: 18 Mar, 2009 19:47:52

Message: 1 of 5

What is the philosophy or reason behind the Mathworks not finally releasing Matlab with a few incrementation operators? (++, +=, etc)

I'm not asking for work arounds or ways how to write my own function to get the same effect. I'm just curious why in the world they don't do this. Seems like it would be a simple thing to do.

Subject: Reason Matlab has never implemented incrementation operators?

From: us

Date: 18 Mar, 2009 19:57:01

Message: 2 of 5

klydefrog
> What is the philosophy or reason behind the Mathworks not finally releasing Matlab with a few incrementation operators? (++, +=, etc)
> I'm not asking for work arounds or ways how to write my own function to get the same effect. I'm just curious why in the world they don't do this. Seems like it would be a simple thing to do...

this issue has been discussed many a times in this NG...
for instance:

http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/db224fe618c29aac

us

Subject: Reason Matlab has never implemented incrementation operators?

From: klydefrog

Date: 18 Mar, 2009 20:24:09

Message: 3 of 5

Thanks. I saw that thread before I posted, but it was cut off before Steven Lord's response.

Subject: Reason Matlab has never implemented incrementation operators?

From: Ryan Ollos

Date: 1 Oct, 2009 05:00:19

Message: 4 of 5

klydefrog <aj00mcgraw@gmail.com> wrote in message <20461488.1237405703543.JavaMail.jakarta@nitrogen.mathforum.org>...
> What is the philosophy or reason behind the Mathworks not finally releasing Matlab with a few incrementation operators? (++, +=, etc)

It would be interesting, given the new object oriented programming capabilities of MATLAB, if it were possible to define operators such as this for your own class. With that in mind, it would also be nice if one could then implement their own ++ operator for the intrinsic classes.

I'm fairly sure that this is not currently possible, although I think it is possible to overload the operators that are pre-defined in MATLAB, such as + and - (via `plus` and `minus` methods). If I remember correctly, I've seen examples of this in pre-2008a classes, but have never tried it myself.

Subject: Reason Matlab has never implemented incrementation operators?

From: Steven Lord

Date: 1 Oct, 2009 13:47:42

Message: 5 of 5


"Ryan Ollos" <ryano@physiosonics.com> wrote in message
news:ha1d12$log$1@fred.mathworks.com...
> klydefrog <aj00mcgraw@gmail.com> wrote in message
> <20461488.1237405703543.JavaMail.jakarta@nitrogen.mathforum.org>...
>> What is the philosophy or reason behind the Mathworks not finally
>> releasing Matlab with a few incrementation operators? (++, +=, etc)
>
> It would be interesting, given the new object oriented programming
> capabilities of MATLAB, if it were possible to define operators such as
> this for your own class. With that in mind, it would also be nice if one
> could then implement their own ++ operator for the intrinsic classes.

You can't define _operators_ for your own classes, but you could define your
own _methods_ for a class. For instance, you could write a method with the
following signature for a handle class:

function plusequals(obj, x)

and use it where you would use a "+=" operator:

plusequals(myobject, incrementdata)

Of course, depending on how 'fancy' you want to get, you could have your
method accept indices as well:

function plusequals(obj, indices, x)

but then you'd have to figure out how you want to handle things like
repeated indices.

> I'm fairly sure that this is not currently possible, although I think it
> is possible to overload the operators that are pre-defined in MATLAB, such
> as + and - (via `plus` and `minus` methods). If I remember correctly,
> I've seen examples of this in pre-2008a classes, but have never tried it
> myself.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/f1-6010.html

and

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/br02zhv.html

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
operator Ryan Ollos 1 Oct, 2009 01:08:12
increment operator Ryan Ollos 1 Oct, 2009 01:08:03
cssm us 18 Mar, 2009 16:00:21
reference us 18 Mar, 2009 16:00:21
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com