|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
- void CCetDlg::OnButton3Ddisp()
- {
- // TODO: Add your control notification handler code here
- Engine *ep;
- if (!(ep = engOpen(NULL))) //打开Matlab引擎
- {
- MessageBox ("Can't start MATLAB engine", MB_OK);
- exit(-1);
- }
- mxArray *xx=mxCreateDoubleMatrix(1,6,mxREAL);
- mxArray *yy=mxCreateDoubleMatrix(1,6,mxREAL);
- mxArray *zz=mxCreateDoubleMatrix(1,6,mxREAL);
- double x[] ={0,1,2,3,4,5}, y[] = {0,1,4,9,16,25}, z[] = {1,1,1,1,1,1};
- engPutVariable(ep,"xx",xx);
- engPutVariable(ep,"yy",yy);
- engPutVariable(ep,"zz",zz);
- memcpy(mxGetPr(xx),x,6*sizeof(double));
- memcpy(mxGetPr(yy),y,6*sizeof(double));
- memcpy(mxGetPr(zz),z,6*sizeof(double));
- engEvalString(ep,"mesh(xx,yy,zz)");
- engEvalString(ep,"xlabel('X(单位:千米)')");
- engEvalString(ep,"ylabel('Y(单位:千米)')");
- engEvalString(ep,"zlabel('Z(单位:千米)')");
- }
复制代码
|
|