简体   繁体   中英

C# - Passing variables to Matlab

Typical google search came out empty, some I'm calling upon your great minds: How can I pass variables from a C# class I'm writing to Matlab (with which I interface via the "NET.addAssembly" function)??

Is there a .dll file I should reference in my C# code? If yes, where is it? Are there some documentations and examples how to pass variables from C# to Matlab? How can I cast C# native variables into Matlab arrays?

Thanks.

It is not straightforward but you can do it.

First, you need to compile a *.DLL Library using C#. You need to create ac# COM interop class using public and private functions. - How to add Microsoft.Kinect.dll to COM Interop C# Class

Then, you need to:

-Run CMD as Administrator

-Open C:\\windows\\Microsoft.NET\\Framework\\v4.0 (or similar) folder

-cd path directory in the CMD window

-copy NAME_OF_YOUR_CLASS.cs to that folder

-copy and paste csc /t:library NAME_OF_YOUR_CLASS.cs

-copy and paste regasm NAME_OF_YOUR_CLASS.dll /tlb /codebase

-Open Matlab and use net.Framework to access the available functions

In MATLAB, you need to:

net = actxserver('ImageCreationMatlab.ImageCreationMatlabClass'); val = net.depthKinectTwo(filename,'kdpt',0,0,1);

This is just an example following the other question DLL.

I'll try to find the links/tutorial for the class creation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM