You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
This function operates in the same manner as the 'sub2ind' method. However, this method is quite faster. It is very similar to the sub2ind.m code.
Example :
>> a = [ 50 50 50 ];
>> b = [ 1 30 49 ];
>> x = sub2ind(a,b,b,b)
x =
1 73980 122449
>> xx = sub2ind_mex(a,b,b,b)
xx =
1 73980 122449
I would like to acknowledge "Marco" from the following thread. He began this bit of code a while ago and posted it here. I have simply taken it and improved its performance a bit. Thank you Marco, I do hope you don't mind what I have done here.
http://www.mathworks.com/matlabcentral/newsreader/view_thread/262036
Update :::
I had unfortunately made a pretty big error in the code. The first while loop did not have sound logic as it was counting backwards. This would work for symmetric arrays only.
My apologies everyone!
Cite As
Christopher Harris (2026). sub2ind_mex (https://www.mathworks.com/matlabcentral/fileexchange/49165-sub2ind_mex), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.1.0.0 (930 Bytes)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
