DLL を 取り込むにはどうすればよいですか?
17 views (last 30 days)
Show older comments
MathWorks Support Team
on 25 Oct 2013
Edited: MathWorks Support Team
on 27 Sep 2023
MATLAB に DLL を取り込んでその関数を使用する方法を教えてください。
Accepted Answer
MathWorks Support Team
on 27 Sep 2023
Edited: MathWorks Support Team
on 27 Sep 2023
LOADLIBRARY 関数 で DLL を MATLAB にロードし、CALLLIB で関数を実行することができます。下記フォルダにサンプルプログラムがありますので、shrlibsample.c、shrhelp.h、shrlibsample.hをコピーしてご確認ください。
$MATLAB\extern\examples\shrlib
($MATLAB・・・MATLABインストールフォルダ)
mex shrlibsample.c
loadlibrary('shrlibsample','shrlibsample.h')
x = [1,2;3,4];
y = calllib('shrlibsample','multDoubleArray', x, 4)
unloadlibrary('shrlibsample')
最初の mex コマンドは、DLL の代わりになる MEX-ファイルを作成しています。既存のDLLを使用する場合は、このコマンドは必要ありません。次の LOADLIBRARY 関数で DLL をロードした後、CALLLIB 関数でshrlibsample.c 中の multDoubleArray を呼び出しています。
multDoubleArray については、2番目の入力引数(4)で1番目の入力引数(x)の要素数を与えており、各要素の3倍の値を出力する関数になります。
0 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB の C ライブラリ in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!