LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab -DLL with mxArray-Type using with Labview

I wrote all my algorithms in Matlab.
The communication with my devices (spectrometer) is done under Labview (VISA).
Because MATLAB dll has input/ output argument in mxArray format, I don't know how to setup 'call library function' to use mxArray.

Is there any possibilities to include the dll which
I get from the matlab-file. Otherwise I' dont know what to do, because I don't want use the
matlab script node from Labview. In this way the application is very slow!
Some ideas?
Thank you!
Ehret
0 Kudos
Message 1 of 10
(6,201 Views)
You have to do 2 things:
1) Learn about Matlab's mxArray format.
2) Write wraper dll that will convert from LabVIEW arrays to Matlab arrays.
0 Kudos
Message 2 of 10
(6,201 Views)
Thank you for the answer.
Do you have any examples or detailed information for writing such a wraper dll.
I don't know how to do this.
I'll be very glad if you can help me,
because its very important.
Thank you very much!
I'm looking forward hearing s.th. from you.
Many Greetings
Ehret
0 Kudos
Message 3 of 10
(6,201 Views)
I'm having the same problem. Have you gotten any farther? Do you have tips for me?
0 Kudos
Message 4 of 10
(6,201 Views)
I haven't examples, but there are lot of examples in Matlab ( if you have Matlab C/C++ compiler).
Also there is disscusion about LabVIEW with Matlab coworking on this forum. Search there some tips.

Good luck,
0 Kudos
Message 5 of 10
(6,201 Views)

I am trying to do the same thing.  And am stuck on how to create the mxArray so I can send it to my MatLab DLL. 

 

Looks like this page has some tips.  I think you need to call a helper function inside the exported DLL to initialize the arrays.

http://www.medicollector.com
0 Kudos
Message 6 of 10
(4,909 Views)

Seems like everyone says you need to create a "wrapper" DLL.  But that is a major PITA.  And I have only heard of 1 person who has been successful (no example LabVIEW code).

http://www.medicollector.com
0 Kudos
Message 7 of 10
(4,893 Views)

To answer my own post:

 

As it turns out, a solution to the mxArray problem is to have your Matlab function use bounded arrays (eg fixed length) instead of unbounded. 

 

Fixed length arrays do not use the mxArray struct.  They are standard pointers which LabVIEW can directly convert to LabvIEW array datatypes.

http://www.medicollector.com
0 Kudos
Message 8 of 10
(4,877 Views)

How do you use bounded arrays in a Matlab function? I have tried several things but seem to get always mxArray type in inputs and outputs.

0 Kudos
Message 9 of 10
(4,524 Views)

I've put together an example on how to do this from start to finish:

 

https://forums.ni.com/t5/Example-Program-Drafts/Walkthrough-for-Creating-a-MATLAB-DLL-That-Can-Be-Ca...

0 Kudos
Message 10 of 10
(3,075 Views)