C에서 MATLAB 호출하기
mxArray를 사용하여 C 프로그램에서 MATLAB® 코드 실행엔진 애플리케이션은 MATLAB을 계산 엔진으로 사용하여 사용자 자신의 C/C++ 프로그램에서 MATLAB을 호출할 수 있게 해 주는 프로그램입니다. C 엔진 애플리케이션을 빌드하려면 mex 함수를 호출하십시오.
참고
C용 Engine API보다 C++용 MATLAB Engine API를 사용하는 것이 좋습니다. C++용 MATLAB Engine API는 엔진 애플리케이션을 작성하기 위한 최신 C++ 기능을 포함합니다. 자세한 내용은 C++에서 MATLAB 호출하기 항목을 참조하십시오. C용 Engine API를 제거할 계획은 없습니다.
엔진 애플리케이션을 사용하려면 MATLAB이 설치되어 있어야 합니다. MATLAB Runtime만 설치된 컴퓨터에서는 MATLAB 엔진을 실행할 수 없습니다.
C 엔진 애플리케이션을 빌드하기 위한 전제 조건은 다음과 같습니다.
C 소스 코드를 작성해 본 경험. C용 Engine API와 C Matrix API 함수를 사용하여 C 소스 코드 파일을 만들 수 있습니다.
MATLAB에서 지원하는 컴파일러. 지원되는 컴파일러의 최신 목록을 보려면 지원 및 호환되는 컴파일러를 참조하십시오.
-client engine옵션을 포함하는mex빌드 스크립트 사용.
C용 Engine API
Engine | MATLAB Engine 유형 |
engOpen | MATLAB Engine 세션 시작 |
engOpenSingleUse | Start MATLAB engine session for single, nonshared use |
engClose | MATLAB Engine 세션 종료 |
engEvalString | Evaluate expression in string |
engGetVariable | Copy variable from MATLAB engine workspace |
engPutVariable | Put variable into MATLAB engine workspace |
engGetVisible | Determine visibility of MATLAB engine session |
engSetVisible | Show or hide MATLAB engine session |
engOutputBuffer | Specify buffer for MATLAB output |
도움말 항목
요구 사항
- Requirements to Build Engine C Applications
Install and configure a compiler and run-time environment so you can build C applications to call MATLAB. - Set Up C Development Environment
Set up a development environment to write C applications that call MATLAB functions.
엔진 애플리케이션 작성
- C 및 Fortran용 MATLAB Engine API
MATLAB을 계산 엔진으로 사용하여 자신의 C 및 Fortran 프로그램에서 MATLAB을 호출합니다. - C 애플리케이션에서 MATLAB 함수 호출하기
C 엔진 애플리케이션engdemo.c를 만듭니다. - Attach to Existing MATLAB Sessions
This example shows how to attach an engine program to a MATLAB session on a Windows® platform that is already running. - Callbacks in Applications
Design user interface callbacks to be evaluated in the context of the base workspace.
엔진 애플리케이션 빌드하고 실행하기
- Windows 엔진 애플리케이션 빌드하기
이 예제에서는 C 예제인engwindemo.c를 사용하여 Windows 플랫폼에서 빌드 프로세스를 확인하는 방법을 보여줍니다. - macOS에서 엔진 애플리케이션 빌드하기
이 예제에서는 macOS 플랫폼에서 빌드 프로세스를 확인하는 방법을 보여줍니다. - Linux에서 엔진 애플리케이션 빌드하기
이 예제에서는 Linux® 플랫폼에서 빌드 프로세스를 확인하는 방법을 보여줍니다.
문제 해결
MATLAB Engine이 실행되지 않을 때 수행할 작업.
Debug MATLAB Function Called by C Engine
How to verify MATLAB functions used in engine applications.
Some MATLAB functions that interact with the user are not supported in engine applications.
MATLAB libraries are not thread-safe.