USING MEX TO SPEED UP THE CODE
Show older comments
I have a matlab code which is computationally intensive and takes more than affordable time to run. I am told mex can be of help. So I have tried converting the code into its C equivalent using Matlab Coder, but am not sure how exactly to compile that in matlab now.
Please help. Thanks in advance
Accepted Answer
More Answers (1)
Sriram Tadavarty
on 1 Aug 2020
1 vote
Hi Yogendra,
Once you generated the mex (MATLAB executable) using MATLAB Coder. Then, observe that there will be a file generated with extensions '_mex'. Use this file to run instead of the actual file, and observe the time taken.
For example, for a function foo, there will be a generated mex file with name foo_mex. Use foo_mex in the same way, the foo is used.
Hope this helps.
Regards,
Sriram
2 Comments
YOGENDRA SINGH BHANDARI
on 1 Aug 2020
Sriram Tadavarty
on 1 Aug 2020
Hi Yogendra,
Thanks for sharing the results. I am actually not sure as what inbuilt MATLAB functions are used in R2RMODEL3.
There could be sometimes, even the mex would take longer time, than native MATLAB code. It depends on the functions that are used. For more information about mex being slower is answered here.
Please have a look and see if it was helpful.
Regards,
Sriram
Categories
Find more on MATLAB Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
