필터 지우기
필터 지우기

Using mex variable_name; where variable_name contains filename to be compiled

조회 수: 1 (최근 30일)
Rupesh
Rupesh 2013년 12월 1일
답변: Titus Edelhofer 2015년 1월 21일
I want to compile a .c file using mex command. It works fine for below format: mex filename.c;
But i have to use mex command runtime and my filename is stored in a variable(Eg. variable_a='filename.c').
When I use mex variable_a; I get an error as variable_a file not found.
How to compile a .c file whose name is stored in a variable using mex command.
Pls help...

답변 (2개)

Martin
Martin 2015년 1월 21일
Although the question is old, Google still finds it, and it took me a while until I found a solution. So someone might find it useful. The trick is to wrap the whole command in an eval:
filename = 'foo.c';
eval(['mex ', filename]);

Titus Edelhofer
Titus Edelhofer 2015년 1월 21일
Another way of doing this is similar to other functions, that are often used this way as save, load, etc. Use the functional form of calling mex:
filename = 'foo.c';
mex(filename);
Titu

카테고리

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