LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling Matlab GUI from Matlab Script Node causes Labview to terminate

When I call Matlab Script Node from my VI to run a complex Matlab GUI, the matlab script starts and gets half way though, then Labview terminates without any confirmation, Matlab command window continues to run.
When I initially tried this the exact same Matlab GUI ran fine without any Labview termination. Now, despite restarting Labview consistently terminates without confirmation when this Matlab script is called.

Any insights/help are appreciated.
0 Kudos
Message 1 of 16
(7,321 Views)
Forgot to include:
Labview 8.2
Matlab R2007a

0 Kudos
Message 2 of 16
(7,318 Views)

Hi Johny,

It sounds like something might have happened to this function - file corruption especially is an option. I would suggest repairing or reinstalling LabVIEW and trying it again. I would also suggest trying the examples to ensure the software is working ok and then trying your code. Let me know what happens!

Examples:

LabVIEW\examples\scriptnode\Differential Equation.llb\MATLAB Script - Lorenz Diff Eq.vi
LabVIEW\examples\scriptnode\Fractal.llb\MATLAB Script - Fractal.vi

Stephanie

0 Kudos
Message 3 of 16
(7,296 Views)
The examples definitely work well.

I'm pretty sure that the problem originates in file read and writes in matlab, I had found an application note regarding save paths when commanding Matlab via ActiveX, but I can no longer find it. If anyone has knowledge of this let me know.
0 Kudos
Message 4 of 16
(7,288 Views)
Hi there
 
I found a way to run advance Matlab GUI's or just m-files in general from within Labview without importing the entire Matlab code.
 
Just simply create a MATLAB script node and type the following

cd 'C:\your\workspace\directory'
run('your_m_file')    %remember to use ' '
 
I found it good to cd to your directory containing your m-files to be sure that Labview can get to them.
Also it wouldn't hurt to put your VI in the same folder.
Somehow it worked better for me not to use the suffix .m when using the run command
 
Hope it works
 
Simon
-----
Labview 8.5
Math Interface Toolkit 1.0.2 for Labview
MatLab 7.3 (2006a)
LabVIEW 8.6 / 2009 / 2010
Vision Development Module 8.6 / 2009 / 2010
VBAI 3.6 / 2010
0 Kudos
Message 5 of 16
(7,181 Views)

Hello,

 

I am using the following command to run a m file in Labview 8.2; but it gives me the following error. can you please guide me in this manner or give a better way to running Matlab R2008a in Labview 8.2?

 

Command: cd 'C:\your\workspace\directory'                , which I wrote it as cd D:m1
                                                                                                                run(m1)

                   run('your_m_file')    %remember to use ' '
Error:Error in function cd at line 1.  The input parameters are not in the required format.
Looking Forward to recieving from You
0 Kudos
Message 6 of 16
(5,743 Views)

Hello,

 

You would need to use MATLAB Script Node to run .m script instead of using MathScript Node.

Andy Chang
National Instruments
0 Kudos
Message 7 of 16
(5,716 Views)

Hi there, 

 

i am looking to get this working on LabView 2012. How do I run an .m file from within the script window? I can open an .m file in editor, but now been able to run it. 

 

Any info appreciated!

0 Kudos
Message 8 of 16
(4,481 Views)

Hi Lauren,

 

This article has a very thorough walkthrough about using .m file scripts with LabVIEW. Hopefully that will give you what you need. Let us know if it doesn't. 

 

Also as a helpful note for future reference, a new post is more likely to get noticed rather then posting a reply to a several year old forum. A rule of thumb is if the forum's last post is over a year old, you may want to consider posting on a new thread, especially in this case where the forum members were working with a much older version of LabVIEW. 

 

I hope this helps, let me know if you have more questions. 

 

 

MATLAB® is a registered trademark of The MathWorks, Inc.

Miles G.
National Instruments
Staff Applications Engineering Specialist
0 Kudos
Message 9 of 16
(4,461 Views)

hi miles, 

 

i found that info before but it does not help me. that refers mainly to using mathscript window in labview, where existing .m files can be run within LabView. I don;t want to do that. 

 

what i want is being able to start a matlab instance triggered by labview and then run an .m file script in that matlab session. how do i do that?

 

thanks,

laurens

0 Kudos
Message 10 of 16
(4,454 Views)