Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
Integrating MS Visual Studio C++ With Matlab Ankit Bhurane

Integrating MS Visual Studio C++ With Matlab Ankit Bhurane

Ratings: (0)|Views: 76|Likes:
Published by Ankit Bhurane
From C++ to Matlab
From C++ to Matlab

More info:

Published by: Ankit Bhurane on Jan 02, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

07/31/2013

pdf

text

original

 
 1 
Although this tutorial is described for the specific version of the software, it shouldwork for other versions too by tweaking few things.
Step 1: Setup path
Set the path for the required libraries. This can be done as follows.Right-click
Computer
 
Properties
 
 
Advanced system settings
 
 
Advanced
Tab
 
Environment Variables
 
User variables for
 
Path
 
Add following paths(separated by semicolon
;
) as shown belowThe path may of course change according to your Matlab installation folder. Typicallyit is
C:\Program Files\MATLAB\R2012b
 
Step 2: Start New Project
Start a New Project with win32 console applications. Add demo files tothe project in the Source.
Step 3: Add files to the project with following code
 
C:\Program Files\MATLAB\R2012b\runtime\win64;C:\Program Files\MATLAB\R2012b\bin;C:\Program Files\MATLAB\R2012b\bin\win64
Integrating MS Visual Studio C++ 2008 (ProfessionalEdition) with Matlab (64 bit) in Windows 7 (64 bit)
Ankit A. Bhurane (ankit.bhurane@gmail.com)
 
 2 
c2m.cpp
 
#include "stdafx.h"#include <iostream> #include <cmath#include "engine.h"using namespacestd; intmain(){Engine *ep = engOpen(NULL);doublex[1000];doubley[1000];doublez[1000];doublet = 0;const doubledt = 0.001; inti,j;doublea,b; mxArray *z_array = mxCreateDoubleMatrix(1000,1,mxREAL); mxArray *a_array = mxCreateDoubleMatrix( 1,1,mxREAL); mxArray *b_array = mxCreateDoubleMatrix( 1,1,mxREAL);double*pz = mxGetPr(z_array);double*pa = mxGetPr(a_array);double*pb = mxGetPr(b_array);for(i=0;i<1000;i++){x[i] = cos(2*3.14*t);y[i] = sin(2*3.14*t);t+=dt;}a = 1; b = 0;for(j=0;j<100;j++){for(i=0;i<1000;i++){z[i] = a*x[i] + b*y[i]; pz[i] = z[i];} pa[0] = a; pb[0] = b;engPutVariable(ep,"z",z_array);engPutVariable(ep,"a",a_array);engPutVariable(ep,"b",b_array);engEvalString(ep,"testPlot");engEvalString(ep,"plot(z);");engEvalString(ep,"axis([0 1000 -1 1]);");engEvalString(ep,"grid on;");engEvalString(ep,"title(sprintf('a = %0.3f \t b = %0.3f',a,b));");engEvalString(ep,"pause(0.1);");a = a - 0.01; b = b + 0.01;}engClose(ep);return0;}
 
 
 3 
Step 4: Setup MS Visual Studio for 64-Bit application
Right-click Project Name
 
Properties
Configuration Manager
(right-top)
 
 Active solution platform
x64
Note: If 
x64
option is absent, search in
<New…>
.
If still unavailable, the 64-bitcompiler seems to be absent. Consider reinstallation of MS Visual Studio with
Full Installation mode.
Step 5: Add additional include directories
Right-click Project Name
 
Properties
C/C++
 
 
Additional Include Directories
 
C:\Program Files\MATLAB\R2012b\extern\include

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->