[英]Calling Matlab from Fortran
我正在嘗試使用CodeBlocks作為我的IDE和GNU Fortran編譯器作為我的編譯器運行fengdemo.f。 它運行在include罰款中,但是無法建立對matlab引擎的任何方法調用
C:\Program Files\MATLAB\R2012b\extern\examples\eng_mat\fengdemo.F|51|undefined reference to `engopen_'|
C:\Program Files\MATLAB\R2012b\extern\examples\eng_mat\fengdemo.F|58|undefined reference to `mxcreatedoublematrix730_'|
C:\Program Files\MATLAB\R2012b\extern\examples\eng_mat\fengdemo.F|59|undefined reference to `mxgetpr_'|
C:\Program Files\MATLAB\R2012b\extern\examples\eng_mat\fengdemo.F|59|undefined reference to `mxcopyreal8toptr730_'|
C:\Program Files\MATLAB\R2012b\extern\examples\eng_mat\fengdemo.F|64|undefined reference to `engputvariable_'|
等等...
我嘗試在線搜索,但在MathWorks或其他任何地方都找不到真正有用的信息。 我還獲得了c ++引擎演示,因此我的path變量和其他類似內容是正確的。
我根本不習慣使用Fortran,因此不勝感激。
PS。 fengdemo.f在extern / examples / eng_mat下,因此我沒有發布任何代碼。
問題:沒有VFC,甚至可能嗎? 如果可以的話,有人可以指出正確的方向嗎?
您也可以“手動”執行某些操作。 在Fortran中,可以使用“系統”子例程來運行系統命令。 例如,如果您在Linux環境中,並且在Fortran代碼中,請包含以下命令:
call system("firefox http://stackoverflow.com/")
fortran程序將打開一個Firefox選項卡/窗口,進入StackOverflow。
在閱讀時,您也可以從終端使用MATLAB(我沒有安裝它)。 例如,您可以調用以下命令來生成圖形。
matlab -nosplash -nodesktop -r "ezplot('x')"
因此,您可以創建一個matlab函數並通過fortran調用它。 Walter Roberson在MATLAB Answers上寫道,您可以使用:
matlab -r 'myfunction(argument1,argument2)';
或更安全:
matlab -r 'try myfunction(argument1,argument2); catch; end; quit'
您還可以使用Fortran創建輸入文件,並在MATLAB中使用它。 這不是自動解決方案,但不需要特殊的編譯器。 但這取決於平台。
如果您使用Windows,則MATLAB支持的唯一Fortran編譯器是Intel Visual Fortran Composer。 GNU Fortran僅在Linux或Mac上受支持。
http://www.mathworks.co.uk/support/compilers/R2013a/index.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.