How to pass a string variable to a mex function

2 ビュー (過去 30 日間)
Álvaro Salcedo
Álvaro Salcedo 2017 年 11 月 22 日
コメント済み: Álvaro Salcedo 2017 年 11 月 23 日
Hello,
I have this command: mex -I/home/user_1/includes
I would like to pass a string variable to a mex function like this:
variable=user_1
mex -I/home/variable/includes
But the problem is that mex takes "variable" instead of the value of variable (user_1).
How can I do that?
Thanks a lot.
  2 件のコメント
Adam
Adam 2017 年 11 月 22 日
編集済み: Adam 2017 年 11 月 22 日
mex does have a function form as well as command form, but for some reason this doesn't appear to be documented in the help so I have also had difficulties understanding how to convert command form into function form for doing something like this. I assume it is possible.
e.g. without flags you can just do:
mex( 'myfile.cpp' )
so I assume you can pass some kind of property, value pairs to this too which would allow a dynamic string.
mex( 'myfile.cpp', '-g' )
works, for example, so maybe you can do the same for -I and pass your folder name as the following argument.
I don't really have a test case handy to try out myself.
Álvaro Salcedo
Álvaro Salcedo 2017 年 11 月 23 日
Hi friend, that works!
Thanks a lot.

サインインしてコメントする。

回答 (0 件)

カテゴリ

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