matlab vc6,VC6调用matlab7里的m程序的案例及方法

void CMatlab7dllDlg::OnRUN()

{

CString str;

mxArray *in1, *in2; /* Define input parameters */

mxArray *out = NULL;/* and output parameters to be passed to the library functions */

double data[] = {1,2,3,4,5,6,7,8,9};

/* Create the input data */

in1 = mxCreateDoubleMatrix(3,3,mxREAL);

in2 = mxCreateDoubleMatrix(3,3,mxREAL);

memcpy(mxGetPr(in1), data, 9*sizeof(double));

memcpy(mxGetPr(in2), data, 9*sizeof(double));

/* Call the library function */

mlfAddmatrix(1, &out, in1, in2);

/* Display the return value of the library function */

str="The value of added matrix is:\n";

str = str + Display(out);

AfxMessageBox(str);

/* Destroy the return value since this varaible will be resued in

* the next function call. Since we are going to reuse the variable,

* we have to set it to NULL. Refer to MATLAB Compiler documentation

* for more information on this. */

mxDestroyArray(out); out=0;

mlfMultiplymatrix(1, &out, in1, in2);

str = "The value of the multiplied matrix is:\n";

str = str+Display(out);

AfxMessageBox(str);

mxDestroyArray(out); out=0;

mlfEigmatrix(1, &out, in1);

str = "The Eigen value of the first matrix is:\n";

str = str+Display(out);

AfxMessageBox(str);

mxDestroyArray(out); out=0;

/* Free the memory created */

mxDestroyArray(in1); in1=0;

mxDestroyArray(in2); in2 = 0;

AfxMessageBox("OK, Finished!");

}

4

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值