Calling MATLAB from C without using Coder? - c++

So I'm currently working on a project where I'm trying to call a MATLAB algorithm from C++ because we're trying to have the final application work on an iOS device.
Is there a way to call that MATLAB code that's been written from C++ without using MATLAB coder?
I've looked into using coder.ExternalDependency class and the official documentation but that uses MATLAB coder and I am trying to avoid that.
I also looked into using feval but all of the examples I could find online were only using pre-built in MATLAB functions like gcd - can I use feval with functions that I wrote myself to call from C++, or do they have to be functions already existing in MATLAB?
Or if anyone has any other suggestions on how to call a MATLAB function in a C++ program that would be great.

Related

CPLEX equivalent C++ of cplexmiqp MATLAB

I have a matlab script, which uses Cplex, to implement in C++. Does the C++ equivalent of the toolbox function cplexmiqp exist ?
If not, how can I solve my problem? I only have the parameters needed to this function to solve the MIP problem (H, f, Aineq, bineq, Aeq, beq, sostype, sosind, soswt, lb, ub, ctype)
cplexmiqp is a convenience function in the CPLEX MATLAB Toolbox API. There is nothing exactly equivalent to this in the C++ API. However, the C++ API is actually more powerful/flexible and you can definitely accomplish the same task. You'll have to build the model using your input data, solve it, and query the solution using methods in the C++ API. I'd suggest that you take a close look at the ilomiqpex1.cpp example that is shipped with CPLEX.

Load matrix from file with use of Octave C++ API

Is it possible to load the matrix in PETSc binary format from external file at runtime with use of Octave C++ API? I've found the Doxygen documentation, but I can't find anything useful among so many items.
Usually I use "PetscBinaryRead.m" when I want to load a PETSc matrix to Octave, but now in C++ I'm really completely lost.
the PetscBinaryRead.m is not part of Octave, we don't know where you got it or even what it does. You can:
reimplement it on C++, C, or Fortran (only you know what it does)
start the Octave interpreter in your C++ and call PetscBinaryRead from there (see the Octave manual on how to create standalone programs or calling Octave Functions from Oct-files

Calling MATLAB or Scilab function from C++ project

I'm trying to access some Scilab functions from my C++ project. I'm working on Windows 7. How can I do that.?
For example,
function [r] = fun(a,b)
r =a+b;
endfunction
How can I tell my C++ project, it should run the Scilab function "fun" and give the parameter a=4, b=9. so that I get their value?
If somebody did this for MATLAB, I think this will be the same here (without using its engine).
A lead would be to use Julia that is quite similar to MATLAB. I'm not sure it's possible yet to compile to a library. The project is based on LLVM so maybe you can generated C code and integrate it with your code.
For MATLAB, you can use the MATLAB compiler, and you should be able find some examples on the MATLAB website.
You will need the Scilab runtime aside, but call_scilab is probably what you are looking for.

How to Integrate matlab with Qt on windows 7

I'm stuck in a very important part of my project as i need to call Matlab functions form Qt 4.7.3 since i use the Qt for my interface (UI) and i want to call matlab function that return results and it appears on Qt UI
i searched many and many and i didn't find any thing that can help even with traditional C++
this will get you started. Basically you compile a dll from within Matlab, and call the dll from your c++ code. Note however: it can take a looong time to load the dll since it loads the matlab runtime etc. Also, all computers you want to use it on need the matlab runtime installed.
A newer option is this one. Haven't tried it yet so I cannot comment on it but it looks promising.
See the documentation for calling Matlab from C++. You'll need to visualize the results yourself, if you want to visualize them in Qt.

MATLAB engine versus libraries created by MATLAB Compiler?

To call MATLAB code in C or C++, how do you choose between using the MATLAB engine and using the MATLAB Compiler mcc to create C or C++ shared libraries from your MATLAB code? What are their pros and cons? For the second method, see http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/f2-9676.html
Are there other ways to call MATLAB from C or C++?
If the computation is linear and long, I would use mcc to compile the code. It is as if MATLAB was simply another library with numerical routines in it to be linked into your program.
If I wanted to provide interaction with MATLAB in my program, where the user could specify any of a large number of statements that would be impossible or merely tedious to code individually, then I would use the MATLAB engine. It is as if I wanted to run MATLAB without the Mathworks' UI.
I have never bothered with opening the MATLAB engine outside of a test.