objective-cmatlabmcc

How to call a MATLAB code from Objective C


I'm planing to write my algorithmic codes in Matlab. And I need to convert .m files into a format where Objective-C can access. When I try mcc, the following error appeared.

The -t switch is no longer supported; the Compiler no longer generates C/C++ 
source code for M-functions (it generates wrapper functions instead, see 
the documenation for -W).

If mcc is not creating C source codes how can i generate wrappers? and do i have to copy both m file and the wrapper in order to make everything working?. And will those wrappers work in iOS??


Solution

  • MATLAB Compiler does not convert MATLAB code into C code, and has not done so for a long time now.

    Instead, it archives and encrypts your MATLAB code and creates a wrapper (which could be an executable, a library or, if you have access also to any of the Builder products, a .NET assembly, a Java .jar file, or an Excel add-in). This wrapper dearchives and decrypts your MATLAB code, and executes it against the MATLAB Compiler Runtime, which needs to be included with your application (but is freely redistributable).

    You are not going to be able to run the MCR on iOS - its footprint is just too big. If you are targeting another platform with Objective-C, you could produce a library using MATLAB Compiler and call that from your Objective-C.

    MATLAB Coder (not the same as MATLAB Compiler) can convert a subset of the MATLAB language into C code. If you are targeting iOS this would be one approach, or you could alternatively run your MATLAB code remotely, and have your app access it via the web.