LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Matlab in Labwindows/CVI

I have a matlab .m file that runs a function. In my Labwindows software, I want to be able to run this function. Is this possible? Thanks.

0 Kudos
Message 1 of 10
(7,415 Views)

It has been a while since I have done this but there are a number of different ways to run .m files from cvi. 

1) If matlab is installed on the target machine, register it as a activex server and use the matlab server interface to directly run the matlab file.

2) Matlab at one time had a toolkit that allowed the creation of a dll from a .m file or files.  This allowed the routines in the .m to be called from cvi just like any other function.  The toolkit included a matlab runtime library that was loaded on each target machine.

3) Matlab at one time had a toolkit that cross-compiled .m files to C code.  Again with the correct runtime library this allowed .m files to be incorporated directly into a cvi application. 

0 Kudos
Message 2 of 10
(7,390 Views)

Here is an example to try:

 

Executing The MathWorks, Inc. MATLAB® Software Commands through ActiveX

http://zone.ni.com/devzone/cda/epd/p/id/2994

 

Thanks,

National Instruments
0 Kudos
Message 3 of 10
(7,372 Views)

There is also an example in the Example Finder called demoforMATLABinterface.cws , just search for MATLAB

National Instruments
0 Kudos
Message 4 of 10
(7,371 Views)

Hello,

 

I tried second idea and Matlab produces a dll and lib file which I used in LabWindows but it dont recognize the lib format. If You did it, could you tell me how exactly? I used this commands:

mcc -W lib:libfoo -T link:lib foo.m bar.m

and

mcc -B csharedlib:libmatrix addmatrix.m multiplymatrix.m eigmatrix.m -v

and the dll and lib files are created but LabWindows dont recognize the lib file.

I have got LabWindows 8.5, Matlab 7.7.0 (R2008b).

0 Kudos
Message 5 of 10
(6,953 Views)

Unfortunately, I did not end up integrating my Matlab script into my Labwindows program. I just decided to simplify everything and rewrite the script in Labwindows so I wouldn't have to deal with extra stuff in dealing with Matlab. Sorry.

0 Kudos
Message 6 of 10
(6,944 Views)

I used Real-Time Workshop and compiled the m file and get the C code but every thing must be static there. I used a command:

emlc -T rtw aproxLSM.m -v

Matlab generates an embedded code in C with headers and everything may be included in LabWindows.

 

I cant use functions from dll in LabWindows becouse they process a specific Matlab arrays (mxArray) wchich can be set only by Matlab functions.

 

0 Kudos
Message 7 of 10
(6,928 Views)

Hi Kamkon,

 

Have you had a chance to look into the example posted by Anna? I've come across discussion forums regarding how to use MATLAB dlls in LabWindows CVI. They are listed below. I hope this is of some help to you.

 

http://forums.ni.com/t5/LabWindows-CVI/How-to-use-a-Matlab-DLL-in-CVI/m-p/548105?requireLogin=False

 

http://forums.ni.com/t5/LabWindows-CVI/Linking-Matlab-generated-lib-files/m-p/283814?requireLogin=Fa...

 

Creating a MATLAB dll is somewhat outside the scope of our suppot. However, I have found a third party link on this topic. Hopefully, it will point you in the right direction.

 

http://www.mathworks.com/support/solutions/en/data/1-18CBI/index.html?solution=1-18CBI

 

Regards.

 

Josh L.

Applications Engineer
National Instruments
0 Kudos
Message 8 of 10
(6,921 Views)

Thank you.

 

I will try this approach mentioned in the link.

0 Kudos
Message 9 of 10
(6,907 Views)

Of all the options, Which can run .m function in a PC without matlab preinstalled?

 

Thats the one I want to try, to generate heavy .wav files (an easy matlab function) from CVI, making the installer lighter.

0 Kudos
Message 10 of 10
(6,091 Views)