Showing results for 
Search instead for 
Did you mean: 

logic of array and plotting functions?


I started to build versatile acquisition programn with labview (with NI cards it seemed to be the best option) and it took quite an effort to adjust the way of thinking while shifting from other programming environments. I start to see the logic behind the labview but I have serious difficulties on figuring out how the labview's array and plotting functions work. Here's a simple example for replacing array subset and plotting it, which just doesn't work as i'd expect. I thought this would first initialize 10 rows, 1000 cols matrix of which the certain row would be replaced (zero padding when new row is longer than the original). The resulting matrix would then be displayed each row having its own windows in the stacked plot. It seems to do something totally different...
0 Kudos
Message 1 of 5
You need to uncheck 'transpose array'. If you look at the 2-D array of numbers it is doing what you want. From the top down the axises are X, Y,Z. Since you have transpose array checked you are only getting ten elements.
0 Kudos
Message 2 of 5
Thanks. That seemed to fix the plotting part but the final array's row lenghts are the same as in the original one, i.e. it doesn't accomodate the larger new array to fit the original one by zero padding it. For example with "build array" function the final array is automatically resized but i guess this is simply not a feature of other array functions.
0 Kudos
Message 3 of 5
Oh, just noticed that this cropping of extra elements is actually said in the help file. I wonder how i missed that... Is there other way to replace arrays of different length than breaking the original one into individual rows and putting them back together with build array function?
0 Kudos
Message 4 of 5
As you noticed, "Replace Array Subset" can only replace array elements that exist. If it's not there, there's nothing to replace.

What you'll need to do is make the array larger by using the "Insert into Array" function. Use this function cautiously though. It requires LabVIEW to dynamically reallocate memory while the program is running, and takes time. If you only do the 'Insert' when needed, you should be OK.

Use the "Array Size" function to get the size of the array to be inserted, then you can choose between the ‘Insert’ or ‘Replace’ functions.


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 5 of 5