06-24-2011 01:26 PM
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.
06-27-2011 12:26 PM - edited 06-27-2011 12:29 PM
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.
06-27-2011 02:25 PM
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
06-27-2011 02:29 PM
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
06-27-2011 02:37 PM
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
06-27-2011 02:44 PM
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.
06-27-2011 02:56 PM
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
06-27-2011 03:08 PM
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?