10-10-2006 08:16 AM
10-10-2006 09:40 AM
10-10-2006 10:04 AM
02-04-2010 07:36 PM
I don't think this thread was ever answered.
I have a Matlab compiled DLL (MEX) which I want to access from LabVIEW. Is this possible?
03-15-2010 07:02 PM
Hi,
This is NOT a solution. I am also facing this problem.
After searching the forum and reading several threads, this one seems to exactly report my problem. As the only potential solution I have seen so far, people have suggested creating wrapper DLLs which is definitely not a practical solution for somebody who does not have the required software installed. The other point is that I have already dealt with several similar problems of passing nasty data to and from "call library function node" successfully just by using LV, but this MATLAB data type: mxArray is another thing!!
Problem Description:
I have a .mexw32 file that is generated by MATLAB from c code. I have changed the extension to .dll which is still allowed in this version of MATLAB. The DLL file contains one function named as "mexFunction" just like every MEX dll. Its prototype is expressed in MATLAB help as follows:
void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
/* more C code ... */
}
Therefore, there are four parameters. two of them are integers, but the other two are arrays of pointers to mxArray structures. There is a nice introduction to mxArray data type in here. It says: "an mxArray is MATLAB's structure for holding data and each element in plhs/prhs holds an mxArray of data."
Just to better understand mxArray, If you also look in MATLAB help under "MATLAB Data", it introduces a function called explore.c which converts the input data into mxArray and shows it on the screen. Here is an example:
>> explore(1001)
------------------------------------------------
Name: prhs[0]
Dimensions: 1x1
Class Name: double
------------------------------------------------
(1,1) = 1001
Using the above information, I have created the following diagram for passing 11 doubles to a MEX dll and get back 52 doubles. Of course, it doesn't work yet! But, maybe I am missing a small point. Does anyone have a suggestion?
Using LV 2009, MATLAB 2009b, Windows XP 32bit
Soroush
03-15-2010 09:49 PM
I have searched a bit more and the only solution seems to be using a wrapper DLL developed in C.
mxArray is an abstract data type in C which means its structure is not publicly accessible! in the above example, I have used just the value (double) and tried to make a structure similar to mxArray, but it is incomplete because it is not possible to find about the exact details of mxArray. (see this)
Sometimes, firm negative answers are good enough!