From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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 script node

Hi,

I have a matlab script node in an application.
This script in the node calls an external mfile.
It runs with out any problems.
If I edit the external mfile the node runs the unedited version.
It will only use the edited version if I close and reopen the project, which closes and reopens the matlab script server.
Is there any way to avoid this behaviour? flush some buffer? without having to close and reopen?

LV 8.5 Matlab 2007b

baldrik
0 Kudos
Message 1 of 8
(3,049 Views)
You can try to manually change the script type to something else and then switch it back, as suggested here for another issue. Right-click on the node and select "Choose Script Server -> XMath Script Node", then switch it back to Matlab. Might work.
0 Kudos
Message 2 of 8
(3,042 Views)
Thanks I will try that. But ideally I dont want to stop the app with the script node in.
Its a large application closing it and reloading configuration data and getting it all up and running is a pain.
It makes testing the external mfile tedious at best.

Is this a known behaviour? I could not find any reference to it on the forums. Is it Labview or Matlab causing the problems.

baldrik
0 Kudos
Message 3 of 8
(3,038 Views)
You can try having a wrapper .m file that your LabVIEW code calls rather than having LabVIEW call your .m file directly. This wrapper .m file then calls your .m file that you want to be able to edit "on the fly". Don't really know if that will work.

I don't really know if this behavior is due to LabVIEW or Matlab. I'd suspect probably both.
0 Kudos
Message 4 of 8
(3,021 Views)
baldrik,

I believe you are encountering this problem because once the LabVIEW application runs and loads the VI with the MATLAB® script node the connection is made to the MATLAB software and everything is loaded into memory.  If you change your file, it will not do anything because the original file is still in memory.

One suggestion would be to have your MATLAB script node in a sub-vi that you can call by reference, and terminate and re-call via your UI.  This way a new connection will be made to the MATLAB software and re-load the newly edited .m file.  See this KB for reference.  I know the KB references an error, but this is something that can happen if you use this method.

Let me know if you have any additional questions.

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

Jared Boothe
Staff Hardware Engineer
National Instruments
0 Kudos
Message 5 of 8
(2,991 Views)
Thanks for the replies.

I managed to solve the problem.
I was editing the file externally, not with the matlab editor.
After an embarassingly long time I thought I'd try typing edit mfile in labviews matlab command window.
Now next time the script node runs matlab knows to reload the mfile.
I am kicking myself for not trying it earlier.
Break points nearly even work. They break but I cannot resume.

My life is now so much easier 🙂

Thanks
baldrik.
0 Kudos
Message 6 of 8
(2,970 Views)
Happy to hear it!
Regards,

Jared Boothe
Staff Hardware Engineer
National Instruments
0 Kudos
Message 7 of 8
(2,958 Views)

Add "rehash path" as the first line of your script.

Message 8 of 8
(2,555 Views)