DLL を 取り込むにはどうすればよいですか?

16 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 25 de Oct. de 2013
Editada: MathWorks Support Team el 27 de Sept. de 2023
MATLAB に DLL を取り込んでその関数を使用する方法を教えてください。

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 27 de Sept. de 2023
Editada: MathWorks Support Team el 27 de Sept. de 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倍の値を出力する関数になります。

Más respuestas (0)

Productos


Versión

R2009a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!