函数检查这一点。而 MATLAB 具有如下的索引编排:第一个元素包含的数据比后面的元素包含的要旧 - 因此,如果标志 AS_SERIES 为 TRUE,您必须在发送数组至 MATLAB 前将其“反转”。基于上述内容,我们得出以下观点:
在 FAR 中打开 <MATLAB>\Bin\<win32/64> 文件夹,其中:
<MATLAB> - MATLAB 主文件夹。
<win32/64> - 用于 32 位操作系统的 win32 文件夹,或用于 64 位操作系统的 win64 文件夹。
对于 Borland C++
,输入:implib libeng.lib libeng.dll。对于 libmx.dll 也是一样。
对于 Visual C++
,输入:lib libeng.dll。对于 libmx.dll 也是一样。
其他编译器
:任何编程语言的任何编译器必须具有该实用程序 - 库管理器,通常这是一个控制台程序 <compiler _folder>\bin\*lib*.exe。
#import "LibMlEngine.dll"
void mlxClose(void);
bool mlxOpen(void);
bool mlxInputChar(char &CharArray[]);
bool mlxInputDouble(double &dArray[],
int sizeArray,
char &CharNameArray[]);
bool mlxInputInt(double &dArray[],
int sizeArray,
char &CharNameArray[]);
bool mlxInputLogical(double &dArray[],
int sizeArray,
char &CharNameArray[]);
int mlxGetDouble(double &dArray[],
int sizeArray,
char &CharNameArray[]);
int mlxGetInt(double &dArray[],
int sizeArray,
char &CharNameArray[]);
int mlxGetLogical(double &dArray[],
int sizeArray,
char &CharNameArray[]);
int mlxGetSizeOfName(char &CharNameArray[]);
#import
#property copyright "2010, MetaQuotes Software Corp."
#property link "https://www.mql5.com/ru"
#property version "1.00"
#import "MatlabEngine.ex5"
bool mlOpen(void);
void mlClose(void);
bool mlInputChar(string array);
bool mlInputDouble(double &array[],
int sizeArray,
string NameArray);
bool mlInputInt(int &array[],
int sizeArray,
string NameArray);
int mlGetDouble(double &array[],
string NameArray);
int mlGetInt(int &array[],
string NameArray);
bool mlInputLogical(bool &array[],
int sizeArray,
string NameArray);
int mlGetLogical(bool &array[],
string NameArray);
int mlGetSizeOfName(string strName);
#import
void OnStart()
double dTestOut[];
int nTestOut[];
bool bTestOut[];
double dTestIn[] = { 1, 2, 3, 4};
int nTestIn[] = { 9, 10, 11, 12};
bool bTestIn[] = {true, false, true, false};
int nSize=0;
string strComm="clc; clear all;";
string strA = "A";
string strB = "B";
string strC = "C";
** 1. 运行 DLL
if(mlOpen()==true)
printf("MATLAB has been loaded");
printf("Matlab ERROR! Load error.");
mlClose();
return;
** 2. 传输命令行
if(mlInputChar(strComm)==true)
printf("Command line has been passed into MATLAB");
else printf("ERROR! Passing the command line error");
** 3. 传输 double 类型的变量
if(mlInputDouble(dTestIn,ArraySize(dTestIn),strA)==true)
printf("Variable of the double type has been passed into MATLAB");
else printf("ERROR! When passing string of the double type");
** 4. 获取 double 类型的变量
if((nSize=mlGetDouble(dTestOut,strA))>0)
int ind=0;
printf("Variable A of the double type has been got into MATLAB, with size = %i",nSize);
for(ind=0; ind<nSize; ind++)
printf("A = %g",dTestOut[ind]);
else printf("ERROR! Variable of the double type double hasn't ben got");
** 5. 传输 int 类型的变量
if(mlInputInt(nTestIn,ArraySize(nTestIn),strB)==true)
printf("Variable of the int type has been passed into MATLAB");
else printf("ERROR! When passing string of the int type");
** 6. 获取 int 类型的变量
if((nSize=mlGetInt(nTestOut,strB))>0)
int ind=0;
printf("Variable B of the int type has been got into MATLAB, with size = %i",nSize);
for(ind=0; ind<nSize; ind++)
printf("B = %i",nTestOut[ind]);
else printf("ERROR! Variable of the int type double hasn't ben got");
** 7. 传输 bool 类型的变量
if(mlInputLogical(bTestIn,ArraySize(bTestIn),strC)==true)
printf("Variable of the bool type has been passed into MATLAB");
else printf("ERROR! When passing string of the bool type");
** 8. 获取 bool 类型的变量 E
if((nSize=mlGetLogical(bTestOut,strC))>0)
int ind=0;
printf("Variable C of the bool type has been got into MATLAB, with size = %i",nSize);
for(ind=0; ind<nSize; ind++)
printf("C = %i",bTestOut[ind]);
else printf("ERROR! Variable of the bool type double hasn't ben got");
** 9. 结束
mlClose();
Exported m-functions – void mlf<NameMfile>(int <number_of_return_values>,mxArray **<return_values>,mxArray *<input_values>, ...),其中: