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
.