易截截图软件、单文件、免安装、纯绿色、仅160KB

c 调用 matlab engine 自定义函数

设置:
1. Tools/Projects and Solutions/VC ++ Directories
    Inlcude files: C:\Program Files\MATLAB\R2009a\extern\include
    Library files: C:\Program Files\MATLAB\R2009a\extern\lib
2. Property
    Configuration Properties/Linker
    General: Additional Library Directories: "C:\Program Files\MATLAB\R2009a\extern\lib\win32\microsoft"
    Input: Additional Dependencies: libmx.lib libmat.lib libeng.lib
   
#include
"stdafx.h"
#include
#include
#include
#include
fun_XY.m file
function Z = fun_XY(X,Y)
Z = X*Y;
<stdio.h><stdlib.h><conio.h>"engine.h"
int
main(int argc, char
**argv)
{
double
X[3][2] = {{1,4},{2,5},{3,6}};
double
Y[2][2] = {{1,2},{3,4}};
int
succeedNotFlag = 1;
Engine *ep;
if
(!(ep = engOpen(NULL)))
{
exit(1);
}
engSetVisible(ep,1);
mxArray *xx = mxCreateDoubleMatrix(3,2,mxREAL);
mxArray *yy = mxCreateDoubleMatrix(2,2,mxREAL);
memcpy(mxGetPr(xx),X,6*
sizeof(double
));
memcpy(mxGetPr(yy),Y,4*
sizeof(double
));
engPutVariable(ep,
"X"
,xx);
engPutVariable(ep,
"Y"
,yy);
int
rows = mxGetM(xx);
int
cols = mxGetN(xx);
////succeedNotFlag = engEvalString(ep,"cd D:\\progX\\CM\\mt");
//succeedNotFlag = engEvalString(ep,"path(path,'D:\progX\CM\mt')"); //will not go to the right routine.
succeedNotFlag = engEvalString(ep,
"path(path,'D:\\progX\\CM\\mt')");
////will go to the right routine.
succeedNotFlag = engEvalString(ep,
"Z = fun_XY_lan(X,Y);"
);
mxArray *z_ptr = NULL;
z_ptr = engGetVariable(ep,
"Z"
);
double *z_c = new double
[6];
z_c = (
double
*) mxGetData(z_ptr);
mxDestroyArray(xx);
mxDestroyArray(yy);
delete
[]z_c;
engClose(ep);
return
0;


相关文档:

[C代码]通讯录

/*****************test.c****************/
#include <stdio.h>
#include <stdlib.h>
#include "addr.h"
int main()
{
 int flag=1;
 while(flag)
 {
  switch(choose_menu())
  {
  case 1:add_person();break;
  case 2:show_person_in ......

C\C++ byte或者char数组转int值

假设有char a[2];
如要把a转换为int值。应是如下写法int b=*(int *)a;
即,先把指针a 转换为一个int指针,然后再此基础上取值。
但是另一种写法 int b=(int)(*a);是不对的,*a 取a的内存单元内容,因为现在a是char指针,所以只会取a[1]中内容,最大为255. 这里要说明的是,在把char或byte数组转换为其他类型的值时,要先 ......

C程序员的情书

#include <stdio.h>
#include <string.h>
int
main(void)
{
char str[] =
"3BVPSq4xF.K?=u#,"
"G'K<MrDnRr7gH%#,"
"XKf<f%G`w^=?C<#,"
"HgU_AnNR?*PDQU#,"
......

c程序设计语言习题1 9

联系1-9编写一个将输入复制到输出的程序,并将其中连续的多个空格用一个空格代替。
#include "stdio.h"
main(){
int c;
int flag;
flag=0;//是否空格标志
while ((c=getchar())!=EOF){
if (c!=32) {
putchar(c);
flag=0;
}else if(flag==0){
flag=1;
putchar(c);
}

/* ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号