Broadcasting and Legacy Code (GNU Octave (version 11.2.0))

#### 19.2.1 Broadcasting and Legacy Code ¶

The new broadcasting semantics almost never affect code that worked in previous versions of Octave. Consequently, all code inherited from MATLAB that worked in previous versions of Octave should still work without change in Octave. The only exception is code such as

    try
      c = a.*b;
    catch
      c = a.*a;
    end_try_catch

that may have relied on matrices of different size producing an error. Because such operation is now valid Octave syntax, this will no longer produce an error. Instead, the following code should be used:

    if (isequal (size (a), size (b)))
      c = a .* b;
    else
      c = a .* a;
    endif