LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab script node user-defined functions (subfunctions)

Hello,

 

I've been working with a Matlab script node that reads and manipulates an image.  I wish to call a user-defined function but I keep receiving an "index exceeds matrix dimensions" error, even when I completely comment out all of the subfunction's code.  I know the error is attributed to the subfunction because commenting out the line that calls it allows the program to run OK.  The complete function and subfunction both run without problems in Matlab but LabView doesn't like the call to the subfunction, nor does it allow the direct definition of a function in another Matlab script node, so I must provide a file path leading into the node.  Is there anything I can do to avoid this, or must I try to directly incorporate the subfunction into the code I'm trying to execute?

 

Thank you. 

0 Kudos
Message 1 of 8
(4,794 Views)

I've found out more...even calling a very simple user-defined function (that doesn't even manipulate the image!  It just displays it in grayscale) and providing the file extension for it gives the same error (index exceeds matrix dimensions).  Any help would really be appreciated.

0 Kudos
Message 2 of 8
(4,771 Views)

Hi ShallowWaters,

 

Are there any variables you are calling the the user-defined function that have the same name as one's in the parent script?  This error often occurs when trying to access a variable in an invalid manner.

 

Have a great day,


Chris V

Applications Engineer
National Instruments
0 Kudos
Message 3 of 8
(4,763 Views)

Did you try including the sub-functions in the same folder or in the folder where the VI set-up indicates the scripts will be?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 8
(4,761 Views)

Chris, 

 

There are not any repeat variable names, the .m user-created function I'm trying to call is basically displaying an image in grayscale (colormap gray; imagesc(imagein);).  My VI is gathering information about an input image and is calling a .m user-defined function to do so.  For debugging purposes, I'm cutting that user-defined function out and using another one that doesn't extract information from the image - it simply displays it.  The built-in imagesc command works fine, but my subfunction imagegr (displays image in grayscale) gives the matrix error.

 

Additionally, if I provide the path to any user-defined function and try to run it (even a completely blank one) it gives me that same error.

 

Thank you

0 Kudos
Message 5 of 8
(4,759 Views)

Ben,

 

The sub-functions, VIs, and image I'm working with are all in the same folder and the corresponding paths provide the correct addresses for each.

 

If it'd help, I could provide the VI and subfunctions I'm trying to work with.

 

0 Kudos
Message 6 of 8
(4,757 Views)

Not me. I don't know anything about script based langauges.

 

I was asking about

 

Tools >>> Options >>> Mathscript

 

which controls where LV looks for sub-functions. There is another one like it for projects.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 8
(4,753 Views)

Ben, 

I'm using the 64 bit version of Labview and can't install the Mathscript toolbox as it hasn't come out for the 64 bit - I'm using the Matlab script node feature for coding, so the option for Mathscript doesn't come up under Options.  Could this be why I can't define subfunctions?  

0 Kudos
Message 8 of 8
(4,750 Views)