LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MathScript adds row to array

Solved!
Go to solution

Hello LabVIEWers,

 

I have recently encountered an issue using MathScript that I do not understand.  When I create a simple 1 dimensional array and then access a single element within that array, MathScript and/or LabVIEW adds an additional row to that array.  This problem becomes apparent when I add the array output to the MathScript stucture and create an indicator.  Attached is a sample VI that illustrates the issue I am encountering.  I have also run the same MathScript code in MatLab and the issue does not seem to occur.  Is there something I am missing? Perhaps a logical reason and explantion for why LabVIEW does this?  I have searched the web, help, and forums so far.  Any help is appreciated.  

 

My goal is to be able to access elements within an array without changing the dimensions of the array, or having to manually delete the added row.

 

Regards,

Doug

0 Kudos
Message 1 of 3
(2,775 Views)
Solution
Accepted by topic author Doug77

Hello Doug77,

 

In the line where you are replacing the 5th element of the array, if you say test_array(5)=77, LabVIEW will not add the extra row. Nearly everything in Mathscript if defined as a matrix. That is why you see the size as 1,11. If you try to manipulate the test_array as a 2D array, by saying test_array(1,5), mathscript assumes it to be a 2D array.

 

Let me know if this helps.

Chinmay Anand Misra
CLD
Technical Marketing Engineer
NI IndRA
Message 2 of 3
(2,731 Views)

Hello Chinmay,

 

Yes, your reply is indeed very helpful and my VI is now functioning properly. It all makes perfect sense now.  So, for a 1D array, an element can be accessed by referencing only its column index when using MathScript.

 

Thank you very much Chinmay.  I have marked your reply as the solution.

 

Kind Regards,

Doug

 

 

0 Kudos
Message 3 of 3
(2,722 Views)