how to change default behavior of 'times' function

3 Ansichten (letzte 30 Tage)
Lanier
Lanier am 26 Mär. 2012
I want to make the times function do element-wise operations by default in the obvious way, even for "non-conformable" matrices. The obvious way to do this would be to overload the times function in the following way:
function y=times(a,b); y=bsxfun(@times,a,b);
The problem with this is that once 'times' is overloaded, bsxfun calls the overloaded function instead of the builtin times function. Any ideas on how to fix this? (Obviously I could hard code the multiplication using the builtin command instead of using bsxfun but that would be slower so I don't want to do that.)

Akzeptierte Antwort

Jonathan Sullivan
Jonathan Sullivan am 26 Mär. 2012
  1 Kommentar
Lanier
Lanier am 26 Mär. 2012
Thanks for that. I figured I wasn't the first person to try this.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by