is it possible to call MATLAB code in a FORTRAN ?

2 ビュー (過去 30 日間)
S.S.
S.S. 2014 年 5 月 5 日
回答済み: James Tursa 2014 年 5 月 6 日
Hey all,
Is it possible to connect a MATLAB function with a FORTRAN code? In fact, I use FORTRAN for programming and not to re-schedule already existing functions in matlab, I try to find a solution to call these functions directly from FORTRAN. Any idea ?
best regards,
S.S.

採用された回答

Friedrich
Friedrich 2014 年 5 月 5 日
Hi,
have a look at the MATLAB Engine
  2 件のコメント
Friedrich
Friedrich 2014 年 5 月 6 日
Moved S.S. answer to a comments:
Hi Friedrich,
I already saw this function, but i need more explanation. how to call the matlab code from a subroutine for example? the steps?
thank you
best regards
Friedrich
Friedrich 2014 年 5 月 6 日
Under the above link there is a subsection called "Call MATLAB Functions from Fortran Applications". Look at it and you will find an example:
"The program fengdemo.F, in the matlabroot/extern/examples/eng_mat folder, illustrates how to call the engine functions from a standalone Fortran program. To see the code, open this file."
Simply follow the doc and you will find what you need.

サインインしてコメントする。

その他の回答 (1 件)

James Tursa
James Tursa 2014 年 5 月 6 日
For mex functions there is a routine called mexCallMATLAB that allows you to call a MATLAB function from your Fortran or C/C++ code. There is no official equivalent for Engine applications. However, there is an FEX submission called engCallMATLAB that mimics this functionality (actually there are two separate submissions, one for C and one for Fortran). It does the work of copying your inputs to the Engine, calling the function, retrieving the outputs, and cleaning the Engine workspace. You can find the submissions here:
There is a short test example supplied with the submissions. You, the programmer, still have to do the work of converting your Fortran arrays/scalars to/from mxArray variables.

カテゴリ

Help Center および File ExchangeFortran with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by