LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use matlab compiled DLL in Labview ?

I have LV 8.5, and am unable to use a matlab compiled DLL in my LV code. I have tried the 'import'  command, but it does not list any functions. However, it does not show any errors during its execution. The existing solutions/responses to this question do not work either. I would also like to know of a way to deal with mxArray datatype. What is its equivalent in C (or any other high-level language) ? How do I retrieve an array that is returned from the matlab dll ?

 

 

0 Kudos
Message 1 of 9
(5,014 Views)

study this.

 

Post if any further help required.

 

Mathan

0 Kudos
Message 2 of 9
(4,994 Views)

I'm assuming you have either Matlab installed or at the very least the Matlab Runtime, otherwise the DLL won't work. The "import" command relies on having a header file. Do you have one? You also need to make sure the DLL has been compiled so that it's compatible with LabVIEW. The most likely problem is name mangling, which also occurs when you try to compile a DLL written in C++. See this post, which contains links to useful posts.

 

The mxArray datatype is a special datatype which is actually a structure. It's complicated. Your best bet is to create a C DLL that acts as an intermediary between the Matlab DLL and LabVIEW. If you are able to, you can, instead, simply call the Matlab code directly using the Matlab script node.

Message 3 of 9
(4,970 Views)
I do have matlab installed on the same system. The header file was also included. The DLL was accepted by LV 'import' command along with the header file. But nothing happens after that - neither error messages nor 'successful completion' messages. A C wrapper for the matlab DLL was attempted, but it has problems with the mxArray** return argument. Is there a working wrapper example that I could use ?
0 Kudos
Message 4 of 9
(4,962 Views)
I have tried using this call library node, but it has problems with mxArray..Any way to overcome that ?
0 Kudos
Message 5 of 9
(4,960 Views)
Yes. Don't. Smiley Wink The intent of the wrapper DLL is to provide a simpler interface for LabVIEW. The wrapper DLL would not return an mxArray datatype. It would return a simple array. The wrapper DLL would handle the dirty work of dealing with the mxArray structure. Note I'm not sure if a wrapper DLL is the best solution in this case. It just seems to me by looking at the information on that datatype that it would be easier to deal with it from C.
0 Kudos
Message 6 of 9
(4,952 Views)

Can anyone provide any example code for creating a wrapper DLL to call a Matlab DLL ... to avoid whole mxArray issue?  Creating a wrapper DLL is a major hassle, and I'm not even convinced it'll work. 

http://www.medicollector.com
0 Kudos
Message 7 of 9
(3,759 Views)

Hi josborne,

 

This thread hasn't been updated in several years, you may want to start a new thread on this issue.

0 Kudos
Message 8 of 9
(3,735 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 9 of 9
(3,693 Views)