matlab教程第十二章应用程序接口api(编辑修改稿)内容摘要:
用。 ( D) MAT 库函数 matClose, matGetArray, matOpen, matPutArray, matPutArrayAsGlobal的使用方法; ( 1) include include include define BUFSIZE 255 // int create(const char *file) { // 9 MATFile *pmat。 mxArray *pa1, *pa2, *pa3。 double data[9] = { , , , , , , , , }。 char str[BUFSIZE]。 printf(Creating file %s...\n\n, file)。 pmat = matOpen(file, w)。 if (pmat == NULL) { printf(Error creating file %s\n, file)。 printf((do you have write permission in this directory?)\n)。 return(1)。 } pa1 = mxCreateDoubleMatrix(3,3,mxREAL)。 mxSetClassName(pa1, LocalDouble)。 pa2 = mxCreateDoubleMatrix(3,3,mxREAL)。 mxSetClassName(pa2, GlobalDouble)。 memcpy((void *)(mxGetPr(pa2)), (void *)data, sizeof(data))。 pa3 = mxCreateString(MATLAB: the language of technical puting)。 mxSetClassName(pa3, LocalString)。 matPutVariable(pmat,LocalDouble, pa1)。 matPutVariableAsGlobal(pmat,GlobalDouble, pa2)。 matPutVariable(pmat, LocalString,pa3)。 memcpy((void *)(mxGetPr(pa1)), (void *)data, sizeof(data))。 matPutVariable(pmat,LocalDouble, pa1)。 mxDestroyArray(pa1)。 mxDestroyArray(pa2)。 mxDestroyArray(pa3)。 if (matClose(pmat) != 0) { printf(Error closing file %s\n,file)。 return(1)。 } // pmat = matOpen(file, r)。 if (pmat == NULL) 10 { printf(Error reopening file %s\n, file)。 return(1)。 } pa1 = matGetVariable(pmat, LocalDouble)。 // if (pa1 == NULL) { printf(Error reading existing matrix LocalDouble\n)。 return(1)。 } if (mxGetNumberOfDimensions(pa1) != 2) { printf(Error saving matrix: result does not have two dimensions\n)。 return(1)。 } pa2 = matGetVariable(pmat, GlobalDouble)。 // if (pa2 == NULL) { printf(Error reading existing matrix GlobalDouble\n)。 return(1)。 } if (!(mxIsFromGlobalWS(pa2))) { printf(Error saving global matrix: result is not global\n)。 return(1)。 } pa3 = matGetVariable(pmat, LocalString)。 // if (pa3 == NULL) { printf(Error reading existing matrix LocalString\n)。 return(1)。 } mxGetString(pa3, str, 255)。 if (strcmp(str, MATLAB: the language of technical puting)) { 11 printf(Error saving string: result has incorrect contents\n)。 return(1)。 } mxDestroyArray(pa1)。 mxDestroyArray(pa2)。 mxDestroyArray(pa3)。 if (matClose(pmat) != 0) { printf(Error closing file %s\n,file)。 return(1)。 } printf(Done\n)。 return(0)。 } //主程序 int main() { int result。 result = create()。 return (result==0)?EXIT_SUCCESS:EXIT_FAILURE。 } ( 2) cd d:\mywork mcc p ( 3) clear cd d:\mywork !exm12022_1 Creating file ... Done load who Your variables are: GlobalDouble LocalDouble LocalString 12 GlobalDouble,LocalDouble,LocalString GlobalDouble = 1 2 3 4 5 6 7 8 9 LocalDouble = 1 2 3 4 5 6 7 8 9 LocalString = MATLAB: the language of technical puting MATLAB 引擎技术的应用 MATLAB 引擎概念和功用 引擎库函数及 C 源码应用程序的编写 【例 】用 C 语言编写调用 MATLAB 引擎计算三次多项式 523 xx 根的源程序。 ( 1) include include include include int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { Engine *ep。 mxArray *P=NULL,*r=NULL。 char buffer[301]。 double poly[4]={1,0,2,5}。 if (!(ep=engOpen(NULL))) { fprintf(stderr,\nC。matlab教程第十二章应用程序接口api(编辑修改稿)
相关推荐
and 390 respectively. It’s not difficult to for us to find some factors to account for this rapid growth. To begin with, the technology in producing mobile phones has advanced greatly in recent years
,2*pi])。 set(gcf,39。 defaultuicontrolhorizontal39。 ,39。 left39。 )。 htitle=title(39。 正弦曲线 39。 )。 set(gcf,39。 defaultuicontrolfontsize39。 ,12)。 uicontrol(39。 style39。 ,39。 frame39。 ,... % 11 39。
(组)的数值解。 例 315 solve(39。 a*x^2 + b*x + c39。 ) solve(39。 a*x^2 + b*x + c39。 ,39。 b39。 ) solve(39。 x + y = 139。 ,39。 x 11*y = 539。 ) A = solve(39。 a*u^2 + v^239。 , 39。 u v = 139。 , 39。 a^2 5*a +639。 )
)s in(在区间 ]4,0[ 上的曲线(图 6 )。 clf。 dx=。 x=0:dx:4。 y=x.*sin(x)。 s=cumtrapz(y)*dx。 plotyy(x,y,x,s),text(,0,39。 \fontsize{14}\ity=xsinx39。 ) sint=39。 {\fontsize{16}\int_{\fontsize{8}0}^{ x}}39。 text(,[39。
( 1) ( 2) 图 22 离散时间系统和混合系统 若干基本模块 ( 1)单位延迟模块 Unit delay ( 2)零阶保持器 ZeroOrder hold ( 3)传递函数型模块 ( 4)组合逻辑模块 Combinational logic ( 5)离散时间积分器 Discretetime integrator 【例 】用组合逻辑模块产生 ba, 的“逻辑和”结果 )1(c
circle_f() which circle_f d:\mywork\ 0 0 图 MEX文件 创建独立的外部应用程序 M 编译器的预配置 一 对 M 编译器 mbuild 应用程序的设置 二 配置正确性的验证 【例 】验证 mbuild应用程序把 C码文件编译成 EXE文件的正确性。 ( 1)先将 matlab\extern\examples\cmath 目录下的 (比方 d