VS2005和Matlab2010b的联合编程的配置。
来源:互联网 发布:阿里云app学生专区 编辑:程序博客网 时间:2024/04/26 18:21
运行Matlab2010b
>> mbuild -setup
Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2010a\sys\lcc
[2] Microsoft Visual C++ 2005 SP1 in C:\Program Files\Microsoft Visual Studio 8
[0] None
Compiler: 2
Please verify your choices:
Compiler: Microsoft Visual C++ 2005 SP1
Location: C:\Program Files\Microsoft Visual Studio 8
Are these correct [y]/n? y
Trying to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R2010a\compopts.bat
From template: C:\PROGRA~1\MATLAB\R2010a\bin\win32\mbuildopts\msvc80compp.bat
Done . . .
Matlab2010b上的配置完毕。
2.配置VS2005
VS2005配置,就是在工具->选项->项目和解决方案->VC++目录->包含文件中包含matlab文件夹下extern/include目录,以及库文件中包含/extern/lib/win32/microsoft目录
新建一个头文件WL_MatlabHeader.h,包含下面的库。方便后面的编程。
#pragma once
#pragma once
#pragma comment(lib, "mclmcr.lib" )
#pragma comment(lib, "libmwlapack.lib" )
#pragma comment(lib, "mclcommain.lib" )
#pragma comment(lib, "libmwblascompat32.lib")
#pragma comment(lib, "rtwcg.lib" )
#pragma comment(lib, "libut.lib" )
#pragma comment(lib, "libmwblas.lib" )
#pragma comment(lib, "physmod_foundation_util.lib" )
#pragma comment(lib, "libmx.lib" )
#pragma comment(lib, "libmex.lib" )
#pragma comment(lib, "ne_rtl.lib" )
#pragma comment(lib, "libmwsl_solver_rtw.lib" )
#pragma comment(lib, "libmat.lib" )
#pragma comment(lib, "ne_mli.lib" )
#pragma comment(lib, "libmwsl_fileio.lib" )
#pragma comment(lib, "libfixedpoint.lib" )
#pragma comment(lib, "mclxlmain.lib" )
#pragma comment(lib, "libmwservices.lib" )
#pragma comment(lib, "libeng.lib" )
#pragma comment(lib, "mclmcrrt.lib" )
#pragma comment(lib, "libmwmathutil.lib" )
#pragma comment(lib, "libemlrt.lib" )
3.电脑环境设置
我的电脑右键-》属性-》高级-》环境变量内的PATH中添加:C:\Program Files\MATLAB\R2010a\bin\win32。(Matlab的安装目录)然后电脑重启。
4.联合编程
当前可以使用Engine变量了。 下面是Matlab的Demo程序。(供参考)
/* $Revision: 1.8.4.2 $ *//* *engdemo.c * *This is a simple program that illustrates how to call the MATLAB *Engine functions from a C program. * * Copyright 1984-2003 The MathWorks, Inc. * All rights reserved */#include <stdlib.h>#include <stdio.h>#include <string.h>#include "engine.h"#define BUFSIZE 256int main(){Engine *ep;mxArray *T = NULL, *result = NULL;char buffer[BUFSIZE+1];double time[10] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 };/* * Start the MATLAB engine locally by executing the string * "matlab" * * To start the session on a remote host, use the name of * the host as the string rather than \0 * * For more complicated cases, use any string with whitespace, * and that string will be executed literally to start MATLAB */if (!(ep = engOpen("\0"))) {fprintf(stderr, "\nCan't start MATLAB engine\n");return EXIT_FAILURE;}/* * PART I * * For the first half of this demonstration, we will send data * to MATLAB, analyze the data, and plot the result. *//* * Create a variable for our data */T = mxCreateDoubleMatrix(1, 10, mxREAL);memcpy((void *)mxGetPr(T), (void *)time, sizeof(time));/* * Place the variable T into the MATLAB workspace */engPutVariable(ep, "T", T);/* * Evaluate a function of time, distance = (1/2)g.*t.^2 * (g is the acceleration due to gravity) */engEvalString(ep, "D = .5.*(-9.8).*T.^2;");/* * Plot the result */engEvalString(ep, "plot(T,D);");engEvalString(ep, "title('Position vs. Time for a falling object');");engEvalString(ep, "xlabel('Time (seconds)');");engEvalString(ep, "ylabel('Position (meters)');");/* * use fgetc() to make sure that we pause long enough to be * able to see the plot */printf("Hit return to continue\n\n");fgetc(stdin);/* * We're done for Part I! Free memory, close MATLAB figure. */printf("Done for Part I.\n");mxDestroyArray(T);engEvalString(ep, "close;");/* * PART II * * For the second half of this demonstration, we will request * a MATLAB string, which should define a variable X. MATLAB * will evaluate the string and create the variable. We * will then recover the variable, and determine its type. */ /* * Use engOutputBuffer to capture MATLAB output, so we can * echo it back. Ensure first that the buffer is always NULL * terminated. */buffer[BUFSIZE] = '\0';engOutputBuffer(ep, buffer, BUFSIZE);while (result == NULL) { char str[BUFSIZE+1]; /* * Get a string input from the user */ printf("Enter a MATLAB command to evaluate. This command should\n"); printf("create a variable X. This program will then determine\n"); printf("what kind of variable you created.\n"); printf("For example: X = 1:5\n"); printf(">> "); fgets(str, BUFSIZE, stdin); /* * Evaluate input with engEvalString */ engEvalString(ep, str); /* * Echo the output from the command. First two characters are * always the double prompt (>>). */ printf("%s", buffer+2); /* * Get result of computation */ printf("\nRetrieving X...\n"); if ((result = engGetVariable(ep,"X")) == NULL) printf("Oops! You didn't create a variable X.\n\n"); else {printf("X is class %s\t\n", mxGetClassName(result)); }}/* * We're done! Free memory, close MATLAB engine and exit. */printf("Done!\n");mxDestroyArray(result);engClose(ep);return EXIT_SUCCESS;}
- VS2005和Matlab2010b的联合编程的配置。
- matlab2010b的安装和破解
- vs2005使用matlab2010b引擎配置
- 两个实用的函数和VS2005部分编程配置信息
- matlab2010b所有的工具箱目录
- 安装Matlab2010b出现一堆warning的问题
- VS2005和Oracle的环境配置
- vs2005+gtk的配置
- vs2005下oracle 10g oci编程环境的配置
- 讨论关于MFC和STL联合编程的问题
- 研究VBA、Word和数据库的联合编程
- Eclipse和Tomcat联合进行网络编程的环境搭建
- ssh联合主键的配置
- VS2005的word2003 VBA编程
- CEGUI 0.8.3在vs2005下的配置和编译
- vs2005和vs2010同时使用opencv的配置问题
- qt配置vs2005的方法
- qt配置vs2005的方法
- 创新工场孵化项目拨号精灵用户数接近100万,做iPhone上最适合中国人的拨号工具
- Hessian远程调用及序列化协议
- ubuntu下eclipse打开java文件,注释内容为乱码,解决方法
- YII Framework学习教程-YII的Model-Action和Models-2011-11-23
- 消灭编译警告(Warning)
- VS2005和Matlab2010b的联合编程的配置。
- 生产者与消费者问题
- EquipmentTreeView--1123
- 转载学习c + +反汇编-来自贡献者feixiaoxing
- 语义的需要
- YII Framework学习教程-YII的V-view的form-view script-2011-11-23
- 函数指针vs函数对象
- 《彻底搞定C指针》指针与数组名
- dns安装与配置,以及基本用法。