Joint simulation of OPNET and MATLAB

Source: Internet
Author: User
Tags opnet

After referring to the articles shared by everyone on the Internet and some books about the joint simulation methods of OPNET and MATLAB, I finally tried it. Now I will share the process with his family and learn and exchange it together ~

The main process is as follows:

  1. Configure the OPENT environment: in Edit --> preference: (My MATLAB is installed in the root directory of drive D)

L Complication settings

Add/ID: MATLAB/extern/include to Comp_flags_common. Here D:/MATLAB is the installation directory of MATLAB. This setting can make the compiler contain some necessary MATLAB header files.

L Link settings

Add the value/LIBPATH: "D:/MATLAB/extern/lib/win32/microsoft/msvc60" to the Bind_shobj_flag variable. Set the value of Bind_shobj_lib to libmx. lib.
Libmat. lib libeng. lib. With this setting, OPNET can call the MATLAB Engine function library.

L environment variable settings:

Include: D:/MATLAB/extern/include;

Add D:/MATLAB/extern/Lib/win32/microsoft in lib;

Add D:/MATLAB/bin/win32 to PATH.

 

2. Programming Guide

1) Add the header file # include "engine. h" to open the computing engine ep = engOpen ();

2) define variables in OPNET, such as double * t;

3) define the data structure mxArray * T of the mx interface of MATLAB and create a matrix. Use the function T = mxCreateDoubleMatrix (, mxREAL) to create a real matrix of three rows and two columns;

4) convert the value of double * t to T and use the statement memcpy (mxGetPr (T), t, 6 * sizeof (double ));

5) introduce T in OPNET into the MATLAB Workspace: Use the function engPutVariable (ep, "T", T), where ep is Engine * ep;

6) perform MATLAB calculations. Use the engEvalString function to execute simple MATLAB commands such as engEvalString (ep, "polt (T, T )"); you can also execute functions in a custom m file, such as engEvalString (ep, "path (path,'m file path ')"); engEvalString (ep, "m file functions ");

7) if a return value exists, use the function to receive the returned value mxArray * T1 = engGetVariable (ep, "T ");

8) convert the returned values to the Data Type in OPNET, for example, double * t1. Use the function t1 = (double *) mxGetData (T1 );

9) destroy all mxArray data. Use the function: mxDestroyArray (T );

10) disable the computing engine engClose (ep );

 

All of this allows you to complete the joint simulation of OPNET and MATLAB ~~~~

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.