How to link .m file and mex file
Show older comments
Hello, I am doing a project in image processing. I have a .m file(which gets an image and perform modulation) and a c mex file (for analog output data generation to USB 205). I want to link the 2 files( .m and mex) so that the modulated data from .m file goes to mex file for data transmission. What are the possible ways to do this?
Thanks in advance!!
6 Comments
James Tursa
on 12 Feb 2020
From you description, just call the mex file from the m file.
Walter Roberson
on 12 Feb 2020
Mex files by definition implement a MATLAB compatible calling interface. Mex is the API used by internal MATLAB extensions (Well, at least Mex is the documented part of it.)
Thus you just make a MATLAB call, providing appropriate parameters like you normally would.
Darshan Ramakant Bhat
on 12 Feb 2020
Some example is present here
Steven Lord
on 12 Feb 2020
Another alternative, if MEX is not a good option for your situation (the interface is fixed and so you can't add a MEX interface for example) would be to try loadlibrary and calllib. See this documentation page for more information.
A R
on 13 Feb 2020
James Tursa
on 13 Feb 2020
Can you describe in more detail what you want the mex function to do? What would be the input(s) and what would be the output(s)? There are examples shipped with MATLAB. Or I can post an example later today if needed, but it would help if I had an idea what you wanted the function to do.
Answers (0)
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!