How do I link outputs from C code written in visual studio into matlab

2 ビュー (過去 30 日間)
H Khalidi
H Khalidi 2019 年 12 月 3 日
編集済み: Dhananjay Kumar 2019 年 12 月 6 日
I'm reading some Matlab documentation about using the API engine and the mex function but im not sure where to start. Any guidance is appreciated :)

回答 (1 件)

Dhananjay Kumar
Dhananjay Kumar 2019 年 12 月 6 日
編集済み: Dhananjay Kumar 2019 年 12 月 6 日
You can call your C code in MATLAB in two ways
  1. Using C MEX API
  2. Using loadlibrary function
MATLAB Engine API is used to call a MATLAB function (like FFT, that will not be easy to write directly in C) from your C code.
C MEX is similar to C, but not exactly C. You have some predefined function and data APIs that you can use to write your code.
For example, you have mexFunction (which has predefined signature) in MATLAB instead of main in C, mexPrintf in MATLAB instead of printf, mwSize and mwIndex instead of int. C MEX uses mxArray datatype for input and output, you have to first extract that data from mxArray to manipulate them. For that, there are C Matrix APIs.
You first write your code in C MEX and then use them after compiling using mex command.
Using loadlibrary, you can load functions from a shared C library (which is purely in C).

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by