C MEX 파일에서 사용자에게 입력 요청하기
MATLAB®은 stdin
과 stdout
을 사용하지 않으므로, 사용자 입력을 요청하기 위해 scanf
와 printf
같은 C/C++ 함수를 사용하지 마십시오. 다음 예제에서는 mexCallMATLAB
을 input
함수와 함께 사용하여 사용자가 숫자를 입력하도록 하는 방법을 보여줍니다.
#include "mex.h" #include "string.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { mxArray *new_number, *str; double out; str = mxCreateString("Enter extension: "); mexCallMATLAB(1,&new_number,1,&str,"input"); out = mxGetScalar(new_number); mexPrintf("You entered: %.0f ", out); mxDestroyArray(new_number); mxDestroyArray(str); return; }
참고 항목
mexCallMATLAB
| input
| inputdlg