LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using array as a MATLAB script input in a subVI - labview crashes

Solved!
Go to solution

@walchu wrote:

Hi Menno_Labviewer,

 

Thank you for the reply. I found it on my own that switching to 2D arrays is a workaround which works. However, I was hoping to understand why is this happening and maybe there is a solution and not a workaround. It seems to me strange that for many years there is this problem but it hasn't been solved. 


There is a combination of reason. First it has to do with the fact that the Script Node seems to make some default assumptions that do not work nicely with the MATLAB COM Server. The LabVIEW compiler tries to do many optimizations and not copy data needlessly unless one of the nodes on the wire has specific flags that indicate to the compiler that "yes I MAY modify this data so don't assume that you can reuse it elsewhere just like that". If LabVIEW then needs to use that data somewhere else (for instance since the wire branches to anywhere else) it will implicitly cause one or multiple of the wire branches to contain an "Always Copy" node.

What seems to happen here is that the interface for MATLAB behind this node does in fact modify/reuse the data buffer but the node indicates to LabVIEW that it won't.

Fixing this sort of things in the code optimizer is not trivial as it has all kinds of dependencies and side effects elsewhere. And to make matters worse, NI has basically discontinued the MATLAB Script Node some time ago.

 

Basically NI has developed in the course of time three ways to interface to MATLAB.

1) MATLAB Script Node (what you tried to use)

2) MathScript Node (their own partly MATLAB compatible math server)

3) MATLAB Node (since 2019 or so)

 

And 1) and 2) are basically declared obsolete now. At least 2) is either already gone completely or going away soon as NI has completely discontinued trying to develop a MATLAB replacement.

 

What this means is that since a few years, development on the MATLAB Script Node was simply stopped and even bug fixes were not planned anymore. LabVIEW is such a complex project that the powers to be rather do not fix a bug unless it is a real security problem, or in an area that has active focus for something else they are working on at that moment. Every single change has a very high probability to fix one bug and cause several others elsewhere.

Rolf Kalbermatter
My Blog
Message 11 of 11
(343 Views)