|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
使用LABWINDOWS/CVI调用MATLAB作为后台的数据传输的问题
通过create activeX cnotroler...生成成的的函数中有一个MLApp_DIMLAppGetWorkspaceData,函数定义如下:
HRESULT CVIFUNC MLApp_DIMLAppGetWorkspaceData (CAObjHandle objectHandle,
ERRORINFO *errorInfo,
const char *name,
const char *workspace,
VARIANT *pdata);
其中VARIANT *pdata这个应该怎么用?这个应该是数据输出
如何控制LABWINDOWS/CVI来获取MATLAB的计算数据?下面的代码目前还存在问题,无法获取到数值
完整代码见附件
int CVICALLBACK runMCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int status;
char filename[300];
char number[300];
int result = 0;
int i;
////////////////
double time[256] = { 0 };
double freq[128];
double vect_r[256],vect_i[256];
double *vecReal = NULL;
double *vecImag = NULL;
size_t
dim1;
size_t
dim2;
//////////////////////////////////////////
static char pathname[MAX_PATHNAME_LEN], dirname[MAX_PATHNAME_LEN];
double num,num1;
static FILE *file_handle;
char *cStr = NULL;
char DA[3200];
double tmp1,tmp2;
VARIANT DATA1;
int DATA2[5];
switch (event)
{
case EVENT_COMMIT:
CA_VariantSetEmpty(&DATA1);
file_handle = fopen ("C:\\matlab\\matlabfiletest\\test.txt", "w+");
result = RunMatlabCommand(hMatlab,"x=1;");
result = RunMatlabCommand(hMatlab,"y=2;");
result = RunMatlabCommand(hMatlab,"z=x+y;");
MLApp_DIMLAppGetWorkspaceData (hMatlab, NULL, "z", "base", &DATA1);
fclose (file_handle);
if (result != SUCCESS)
{
MessagePopup ("ERROR", "Error in running MATLAB Script");
return 0;
}
break;
}
return 0;
}
matlab.rar
(1000.75 KB, 下载次数: 67 )
|
|