simpleeng.c
来自「详细的介绍MATLAB 7 的功能」· C语言 代码 · 共 44 行
C
44 行
/*necessory header file*/
#include "engine.h"
#include "stdio.h"
#include "conio.h"
#define BUFFERLEN 256
/*main function*/
void main()
{
Engine *ep;
char cmd[BUFFERLEN];
int i=0;
int status=0;
/*open the engine*/
ep=engOpen(NULL);
if(ep==(Engine*)NULL){
printf("error:can't open MATLAB engine\n");
exit(-1);
}
/*execute MATLAB command*/
engEvalString(ep,"A=zeros(1,10);");
/*wait for a moment...*/
printf("\n please check the outcome in the MATLAB command line!\n");
printf("\n press any key to continue...\n");
getch();
/*execute other MATLAB commands*/
for(i=10;i<20;i++){
/*the command to be executed in MATLAB*/
sprintf(cmd,"A(%d)=fibonacci(%d);",i-9,i);
/*execute the command*/
engEvalString(ep,cmd);
}
/*wait for a moment...*/
printf("\n please check the outcome in the MATLAB command line!\n");
printf("\n press any key to continue...\n");
getch();
/*close the MATLAB engine and release memory*/
status=engClose(ep);
if(status!=0){
printf("can't close the engine\n");
exit(-1);
}
printf("\n MATLAB engine is successfully used.\n");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?