03-30-2017 06:34 PM - edited 03-30-2017 06:36 PM
Hi guys i have successfully called MATLAB code in one subVI of my Main VI. It seems once you have a subVI with MATLAB node in it, the MATLAB script server will be automatically lauched when you call the main VI.
But as a part of a project with hundreds of subVIs, it is not necessary to start the main VI with MATLAB each time. One reason is the launch of MATLAB takes some time, and another is not every user need MATLAB.
Is that possible that we only launch the MATLAB script server when needed? Like when the user click a "Lauchn MATLAB" button, then the MATLAB script server then start to launch?
Thanks!
Solved! Go to Solution.
04-03-2017 01:35 PM
Hello wangyich,
You can include in your main VI an event structure to indicate LabVIEW when you want the Mathscript to execute. Here is a link that explains the use of these structures.
http://www.ni.com/white-paper/3331/en/
You can add a button on the front panel and make an event for that button.
Hope this helps.
Regards.
04-24-2017 05:46 PM - edited 04-24-2017 05:49 PM
I used an event structure and call the VI containing my MATLAB node by its reference. However, the Matlab Script Launched whenever i opened the VI ( see picture).
Is there another way to launch the MATLAB Script only when I click the "Initialize Matlab" button?
Thanks.
04-24-2017 05:53 PM - edited 04-24-2017 06:02 PM
Your first reference you feed into the "vi->name" property node is allready an opened reference to the vi that contains the matlab code. Thats why matlab is loading when you open this vi.
Open the VI reference by a filepath instead, then it will work (i use this exact method in my program).
Edit: See the image below - it does not matter where you place this code, a event structure is not necessary. As soon as the "Open VI Reference" node is called matlab will start.
04-25-2017 05:17 PM
Thanks man!
After making this change it solved my problem!