Quote:

> I discovered a couple of shortcomings in the functions I posted previously

> so I rewrote them. They now correctly handle operations with scalers and

> should be a little faster when the arguments are already the same size.

> My preference is for The MathWorks to leave the use of the overloaded

> operators up to the user, but if you want to use them you can. This

> version of minus.m can easily be modified for +, ./, etc.

> function z = minus(x,y)

> %MINUS Subtraction (overloads minus for doubles).

> % X - Y returns the difference of X and Y. X and Y must be the same size

> % unless one of them is a scalar or they differ in only one dimension

> % and that dimension is 1 for either X or Y in which case the data for

> % that dimension is replicated appropriately.

> %

> % For example,

> % [1 2 3;4 5 6] - [100 200 300]

> % is the same as

> % [1 2 3;4 5 6] - [100 200 300;100 200 300]

> % where the single row has been replicated.

Seems a bit strange. As pointed out, when do you get errors? What if

everyone had their own definition of minus - don't things become

impossible to port?

Another way is the APL/J approach - higher level

functions that operate on other functions. In this case rank:

a=. 2 3$i. 6

a

0 1 2

3 4 5

b=. 100 200 300

b

100 200 300

a + b

length error

a +"1 b

100 201 302

103 204 305

--

Sam Sirlin