From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab functions in Labview

Hello, I've been reading through Google and through many posts which addresses same/similar issues and I did came to know of the MATLAB script which is already embedded in Labview to use. However, my problem is that I have lots and lots of Matlab functions. The Matlab Script is specific for one function only with putting in arguments and getting output. I don't foresee myself using this since then I would have to create hundreds of these little nodes and each different for the equivalent Matlab code. I found through ActiveX control that I can select the Matlab (DIMLApp) Class and Properties, I just can't find any documentation on how to use these and implement them. I believe these would be more helpful since it would be a more generic form where I can hopefully put in name of m-file, path, and input and outputs, so I wouldn't have to copy and paste all individual Matlab scripts. I imagine it would be Labview sending input like name of function and path, then goes to Matlab where it does its thing, then back to Labview to display result. I found "Feval", which I believe it's "function evaluate", but I can't see anywhere any documentation as to what the input parameters mean like what's "bstrName". Only successful thing I've done so far is actually use the "MaximizeCommandWindow" and "MinimizeCommandWindow" 😐 . Any help would be greatly appreciated. Thanks
0 Kudos
Message 1 of 4
(3,785 Views)

@Merb wrote:
 The Matlab Script is specific for one function only with putting in arguments and getting output.

I'm a little confused by this statement. There are definitely ways in LabVIEW to evaluate more than one function in a script node.

 

You basically have three options:

 

  1. MATLAB script node - this node calls MATLAB through ActiveX. MATLAB must be installed on the computer you run this on but you have full access to MATLAB functionality.
  2. LabVIEW formula node - this node is fully contained in LabVIEW. There aren't a huge number of advanced functions available, but for most scripting it is sufficient.
  3. LabVIEW mathscript node - this node is also fully contained in LabVIEW but requires the mathscript module. There are many more functions available than in the formula node. The scripting looks very similar to MATLAB syntax, but it is slightly different.

Check out this article for some more details: Scripting Languages in NI LabVIEW (this article doesn't have much infornation on the MATLAB node - NI and MathWorks don't get along very well)

Chris
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 2 of 4
(3,656 Views)

What is it you are actually trying to do.  Any of the options you are looking at will add overhead.  When you start to add overhead to over a hundred functions, that starts to add up.

 

Unless there's a valid need, you should choose one platform and stick with it.  You'll have better code that way.

0 Kudos
Message 3 of 4
(3,629 Views)

Wow thanks for replying and providing some feedback. I had pretty much given up in finding hints through this community Smiley Sad

 

The issue is that legacy products were tested via Matlab scripts and we are now doing testing through Labview. In order to support this legacy products and continue testing/supporting them, I'd like to have a Labview platform that would call to Matlab code process it and return result back to Labview. That being said, the options you outlined are useful if to were to make something from scratch. The script node, I would literally have to rewrite all Matlab code into the script node and add the input and output of Labview, this would take forever and I don't want to do that. I was hoping for a more generic way of transfering functions with pertaining arguments. All Matlab needs is the directory path of where the Matlab functions are, so through Labview open that directory path and from Labview send function name with arguments. Similiar as to looking for a function in a header file. 

 

Anyhow I've solved my problem by pretty much using external Matlab commands via DOS command line. Opposed to the script node, this is a more generic use since I can reuse all those hundreds of Matlab scripts without writing them in the script node. I just send in the path where Matlab functions are, name of function with arguments and well in that path should be a script containing such function and process it with the arugments I send from Labview. The output is then saved into a file of which then I read from Labview.  It works, but somehow I don't know why Labview is taking 3-4 seconds to read from a file, I'm trying to fight that off, I've found a workaround, but well, another issue.

 

thanks for the suggestions and for the resposne, I can only hope any future person with similar question can understand my giberish Smiley Frustrated and articulate it better. 

 

 

 

 

0 Kudos
Message 4 of 4
(3,612 Views)