How to call the mex function

조회 수: 1 (최근 30일)
Zaw min Han
Zaw min Han 2020년 2월 27일
답변: Chaitanya Mallela 2020년 3월 4일
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
I have C++ code written that i want to import to matlab, is there a step by step method to implemant the C++ code into matlab i dont have a header file just main.c file .

답변 (1개)

Chaitanya Mallela
Chaitanya Mallela 2020년 3월 4일
Configure mex compiler either C or C++ by using MATLAB command in the command window
mex –setup C / C++
This will automatically set to default C / C++ compiler in the hardware if only one compiler is present else it displays a list of compilers and a compiler has to be chosen.
Create a gateway routine mexFunction in the main file and include mex.h header file.
Call the main function inside the mexFunction.
Create a MATLAB executable to the main function by using MATLAB Command
mex main.c
Run the executable (main) in the command window
The above documentation provides a C-Mex standalone example for gateway routine mexFunction implementation

카테고리

Help CenterFile Exchange에서 Write 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