php調用matlab


matlab太大了,想導出一個可執行的文件,exe或jar或dll吧,然后用程序調用。

我導出的exe,用php調用

安裝matlab,安裝vc6編譯器。沒用過C++,下了個VC6.0安裝了,系統就有vc6編譯器了。

Matlab命令行窗口:

>> mex -setup
Please choose your compiler for building external interface (MEX) files: 
 
Would you like mex to locate installed compilers [y]/n? y
 
Select a compiler: 
[1] Lcc-win32 C 2.4.1 in C:\matlab\sys\lcc 
[2] Microsoft Visual C++ 6.0 in C:\Program Files\Microsoft Visual Studio 
 
[0] None 
 
Compiler: 2
 
Please verify your choices: 
 
Compiler: Microsoft Visual C++ 6.0 
Location: C:\Program Files\Microsoft Visual Studio 
 
Are these correct [y]/n? y
 
Trying to update options file: C:\Documents and Settings\cnic\Application Data\MathWorks\MATLAB\R2009a\mexopts.bat 
From template:              C:\matlab\bin\win32\mexopts\msvc60opts.bat 
 
Done . . . 
 
************************************************************************** 
  Warning: The MATLAB C and Fortran API has changed to support MATLAB 
           variables with more than 2^32-1 elements.  In the near future 
           you will be required to update your code to utilize the new 
           API. You can find more information about this at: 
           http://www.mathworks.com/support/solutions/data/1-5C27B9.html?solution=1-5C27B9 
           Building with the -largeArrayDims option enables the new API. 
************************************************************************** 
 
>> mbuild -setup
Please choose your compiler for building standalone MATLAB applications: 
 
Would you like mbuild to locate installed compilers [y]/n? y
 
Select a compiler: 
[1] Lcc-win32 C 2.4.1 in C:\matlab\sys\lcc 
[2] Microsoft Visual C++ 6.0 in C:\Program Files\Microsoft Visual Studio 
 
[0] None 
 
Compiler: 2
 
Please verify your choices: 
 
Compiler: Microsoft Visual C++ 6.0 
Location: C:\Program Files\Microsoft Visual Studio 
 
Are these correct [y]/n? y
 
Trying to update options file: C:\Documents and Settings\cnic\Application Data\MathWorks\MATLAB\R2009a\compopts.bat 
From template:              C:\matlab\bin\win32\mbuildopts\msvc60compp.bat 
 
Done . . . 

mex -setup

mbuild -setup

都選VC6

M文件:funBt_fun.m

隨便一點了就

function c= funBt_fun(input)
c=input+1;

Matlab命令窗口:

cd XXX進入M文件所在路徑

mcc -m funBt_fun.m          進行編譯

生成funBt_fun.exe

PHP調用:

$commandBt="E:/funBt_fun.exe Fringillidae";
system($commandBt);

注:不要用Matlab自帶的編譯器啊,用VC6

哥用自帶的,也可以導出exe,奇怪的是在DOS下可執行,在PHP下就調用不了。沒錯誤,沒反應,調試都沒法調,苦死。。

dll C++的兄弟請參考http://developer.51cto.com/art/200909/150944.htm

jar包的話,會用java的應該都沒問題吧


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM