LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing autoindexed array into matlab script node

I am extremely new to labview so forgive me if I'm not explaining my issue well.  I have an issue where when I wire a 1d array to a matlab script node I get the error code

 

"Error 1050 occurred at LabVIEW: Error occurred while executing script. Error message from server: ??? Index in position 1 is invalid. Array indices must be positive integers or logical values."

 

The array is generated by an conditional autoindexing tunnel so that I can generate the array only when the start record button is true.  The code is attached, thanks for any help.

 

image.png

 

0 Kudos
Message 1 of 4
(2,501 Views)

Does it work with a array constant?

 

Do you get the error during edit time or during running? Is it the output error of the node, or a popup?

 

If it works with a constant, it seems like a bug. I'd try to get the array size, and reshape the array to that size. That doesn't do too much useful, but might fix the array if it's wrong. Or try an Always Copy function. Both are not ideal, as both will probably copy memory, but it could be a workaround.

0 Kudos
Message 2 of 4
(2,459 Views)

So I tried running the script node with a array constant and it would not function and returned the same error. The error occurs after the program is stopped and the error is shown as a pop up window. 

0 Kudos
Message 3 of 4
(2,454 Views)

I'm no MATLAB expert, but it doesn't seem like a LabVIEW error.

 

Google for MATLAB+matlab+"Index+in+position+1+is+invalid" returns similar issues. And presumably solutions (again, I'm no expert).

 

If I had to guess, the two peakfind functions return a scalar, but are stored in an indexed array. Are those indices set? Or NaN by default? Something like that, after glancing at the google results.

 

I wander though if you can get rid of the popup by wiring the error out of the node. The error will still be there, but you shouldn't want popups in sub VIs.

0 Kudos
Message 4 of 4
(2,446 Views)