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

Hello

 

I am having troubles in creating a subVI that includes a matlab file which has an array as an input.

 

I have created a VI, that executes a simple matlab script, having an array as an input and an array as an output. This worked fine, untill i assigned the terminals in order to use it as a subVI.

After the terminals have been assigned, labview instantly crashes when running the file.

I also created a VI to test the subVI, but I couldn't get it to work at all, labview always crashed...

Does anyone know a solution to my problem? They only thing i can think of is to not use it as a subVI, but then my main file will get huge, as all the matlab code would be included in there...

 

attached are both files, so that you better understand my problem. (test_... is the main file)

 

any help will be greatly appreciated!

 

- Jarno

 

edit: I'm using labview 2013 with windows 7 and matlab 2014

Download All
0 Kudos
Message 1 of 11
(5,457 Views)

Does noone have any idea, why this is? I suspect it is a bug, though I am a labview beginner, so it still might be that I made a mistake...

0 Kudos
Message 2 of 11
(5,427 Views)
Solution
Accepted by Jarno

Hey Jarno, 

 

This is indeed a bug, unfortunately. Currently tracked using Issue ID number 446431. The issue will arise when passing an array of doubles into the Script Node. The only "workaround" at the moment is to use an array of singles instead. We are currently looking into the issue to identify a fix.

Tim A.
Message 3 of 11
(5,401 Views)

Ok, thanks for the workaround.

 

- Jarno

0 Kudos
Message 4 of 11
(5,382 Views)

Hey Jarno, 

 

I did some playing around with this (sorry for the delay) and another workaround we can use is adding an Always Copy to the array before passing it into the Script Node. This will allow you to continue using Double precision arrays instead of going to Singles.

 

ScriptNodeWorkaroun_AlwaysCopy.PNG

 

It looks like there is an issue with the array copy that is passed into the SubVI through the terminal, but we can get around it by making a new copy that the Script Node can properly work with. 

Tim A.
Message 5 of 11
(5,266 Views)

We had similar issues when getting arrays out of the MATLAB script node. The solution with "Always Copy" also worked for that case.

Message 6 of 11
(3,158 Views)

Menno_Labviewer, how did you use "Always Copy" for "out of the MATLAB script node"? I have a similar issue. My Labview crashes when I try to get out an array from MATLAB script node.

0 Kudos
Message 7 of 11
(1,717 Views)

Hi Walchu,

 

You just have to "do" something after getting the data out of the script server. At the time, I implemented this by adding 0 to an array before connecting it to an indicator. I assume it works the same when using the, arguably more elegant, "Always copy" function that was mentioned earlier in the post.

 

I also found this hint to switch from 1d to 2d arrays useful: https://forums.ni.com/t5/LabVIEW/Labview-2011-FDS-64bit-crashes-when-saving-a-vi-with-MATLAB-node/td...

0 Kudos
Message 8 of 11
(1,705 Views)

I would assume (wild guess really) that it has to do with the memory manager and it not realising that the memory is used and freeing/reusing it. By adding an Always copy it's flagged as used or something like that. Unless the array is very large it's a fine workaround. 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 11
(1,699 Views)

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. 

Message 10 of 11
(1,684 Views)