LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

matlab-labview

I want to be able to call MATLAB Compiler generated dll shared library
without invoking MATLAB (otherwise I would have use the MATLAB script
node). I thought this will allow me to develop my algorithm in MATLAB,
then packaged it in dll and use it in LabVIEW without needing MATLAB.

Because MATLAB dll has input/ output argument in mxArray format, I don't

know how to setup 'call library function' to use mxArray. I tried using
pointers and array in 'call library function', but I got the error
message that the file is not a 32bit dll.

Have sambody an answer how to use and setting up 'call library function'

with MATLAB Compiler generated dll stand-alone shared library?

Reagrds TAnja
0 Kudos
Message 1 of 13
(8,677 Views)
I'm afraid it will be difficult this way.
I always write a DLL between Matlab and LabVIEW. To compile this interface DLL you should use both LabVIEW and Matab typedefs. This way you are calling your DLL passing and receiving mxArrays. Then in C you can convert them to LV format. The tricky part is reserving the memory. You can either you LV memory management functions, or get the size of your array first then initiate the right size of array in G. After that you can pass this array as a pointer.

This usually works.

regards,

Andras Ferencz
Message 2 of 13
(8,675 Views)
Andras,

Thank you for your comment. Are there any example files (creation of DLL between Matlab and LabView) available?

Thanks again.

John
0 Kudos
Message 3 of 13
(8,675 Views)
Please look at the attached file. It compiles some of my experiences doing this.

Alberto
Message 4 of 13
(8,675 Views)
Hi,

I have gone through the tutorial attached. It was very useful. Presently I am working on Labview 7.0 and Matalb R13 version. I am facing some problems in creating wrapper dlls. Could u please provide me any tutorial/info on wrapper dlls (How to create wrapper dlls for Matlab).

Thanks in advance
Best Regards
Rasul.
0 Kudos
Message 5 of 13
(8,675 Views)
I am using Matlab 7 (R14) and they've completely changed what files get compiled and so now the above procedure does not work.

Could anyone tell me how to do the above for R14. I have no experience of linking code, so I dont know what headers need to be included etc.

Also, is there any chance of seeing a simple example, including all the source code in Matlab, c code and the linking in Labview (I have 7 & 7.1). For example use Labview to call a Matlab generated dll to return y = 2*x.

Once I have this, I think I can work the rest out.

Thanks
0 Kudos
Message 6 of 13
(8,675 Views)
OK, I've looked around the archive and sort of found how to do this.

However, I cannot get my implementation to work. I run the dll in Labview and its fine once. But when I run it again its wrong.

PLEASE someone help me here - I dont know why it dont work.

I've attached my files for you to see.

You can compile the code using:
mcc -l doubleanumber.m func_wrapper.c
Download All
0 Kudos
Message 7 of 13
(8,674 Views)
 
I was reading this post because I am trying to optimize a real time image processing system I have. i am capturing images with labview pci capture card and then using matlab script node to process each frame. Does the method of converting the matlab to dll and then calling from matlab provide any benefit ?
0 Kudos
Message 8 of 13
(7,894 Views)
Using the Matlab Script Node creates a small amount of overhead when converting the Matlab code for use in LabVIEW. Therefore, there is a small advantage in compiling your matlab code into a dll, and calling it from Matlab, as it is slightly optimized, especially if you are using image processing functions that are not available in LabVIEW.
0 Kudos
Message 9 of 13
(7,860 Views)
I am now doing the same thing as you ,do you solve the problem
0 Kudos
Message 10 of 13
(5,691 Views)