?? simpleeng.c
字號:
/*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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -