필터 지우기
필터 지우기

How to solve big sets of linear equations in c++ using MATLAB functions

조회 수: 2 (최근 30일)
Meytal
Meytal 2011년 8월 1일
Hi, I need to solve a big set oflinear equations in a program in c++. I read about MEX files, but as I understood, when using MEX file, the program must be run eventually from matlab, and you can't work with the output again in c++ in the same program. I need a solution that will let me try to solve the set using solve() or inv() and if not succeeded, the solution will let me guess some of the variables and try againin the c++ program. Does any of you know of this kind of solution, or something similar? A solution like library matlab functions in c++ would be the most suitable, I guess..

답변 (2개)

Walter Roberson
Walter Roberson 2011년 8월 1일
solve() cannot be compiled in to an executable using the MATLAB compiler, but it is possible to make a call to the MATLAB engine to invoke solve() from a real MATLAB session.
inv() is usually a mistake, numerically.
mldivide() is what you would normally use for linear equations.
  댓글 수: 1
Meytal
Meytal 2011년 8월 1일
Hi, thanks for your answer.
my problem is not yet which function to call, but how to do it from c++ program and not from MATLAB, cause I can't run the c++ program and then the MATLAB, I need to be able to solve the set in c++ environment...
and I'm clueless about any solution available..

댓글을 달려면 로그인하십시오.


James Tursa
James Tursa 2011년 8월 1일
In a mex routine you can iteratively call MATLAB functions via mexCallMATLAB to do the solving etc. You can pass variables back & forth all you want. Everything you have described so far is possible in a mex routine. You could also use an Engine application to do this. In either case you will need to become familiar with the MATLAB External Interfaces API section of the doc.
  댓글 수: 1
Meytal
Meytal 2011년 8월 1일
thank you :)
do you know of any good guide for using mex functions?
I am not familiar of any of this..

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by