Code covered by the BSD License  

Highlights from
bsxops

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 77.41 KB File ID: #23821

bsxops

by Bruno Luong

 

18 Apr 2009 (Updated 13 Jun 2009)

Force MATLAB operators to behave BSXFUN-like

| Watch this File

File Information
Description

Force MATLAB operators to behave BSXFUN-like, i.e. operate multi-dimensional array with automatic expansion. Here is an example:
 
>> bsxops(1) % Activate the bsxops mode

>> (1:3) + (4:5)'.*reshape([10 11],[1 1 2])
ans(:,:,1) =

    41 42 43
    51 52 53

ans(:,:,2) =

    45 46 47
    56 57 58

>> bsxops(0) % Compatible mode
>> (1:3) + (4:5)'.*reshape([10 11],[1 1 2])
??? Error using ==> times
Number of array dimensions must match for binary array op.

Acknowledgements
This submission has inspired the following:
Embiggen
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
21 Apr 2009

Correct BUG min/max (two-output call)

13 Jun 2009

Direct use (not overloaded): Explicit bsx (sub)classes objects can be created and used. Subclasses works on Matlab versions that support Object Oriented Programing (OOP), i.e., 2008A onward.

Overloading bsxops is still working on previous Matlab.

Tag Activity for this File
Tag Applied By Date/Time
bsxfun Bruno Luong 20 Apr 2009 11:57:27
array Bruno Luong 20 Apr 2009 11:57:27
expansion Bruno Luong 20 Apr 2009 11:57:27
operator Bruno Luong 20 Apr 2009 11:57:27
elementwise Bruno Luong 20 Apr 2009 11:57:27
hadamard Bruno Luong 21 Apr 2009 03:07:41

Contact us at files@mathworks.com