12-23-2008 11:49 PM - edited 12-23-2008 11:50 PM
I read some data from a text file and formed an array according to my requirement(the attached picture will illustrate).
What my problem was when i used this array in another vi through connector panes, all the rows in the array got the width of the maximum size row and are filled with zeroes.
How to eliminate this? I need the rows to be terminated with its own values, here in my case first two rows should have 5 elements in the array, third row 7 elements and so on...
Solved! Go to Solution.
12-23-2008 11:56 PM
You can't do what you want to do because LV does not support sparse arrays. All rows have the same number of columns and all columns have the same number of rows. There are a couple things you can do.
Create a 1D array of numbers and put it inside a cluster, now put this cluster (containing the 1D array) inside another 1D array. Because the inner array is inside a cluster each element of the outer array can contain an array with a different number of elements.
Alternately, you could modify the data in the array such that the first column holds a count of the number of valid elements in each row.
There are probably other solutions depending upon what exactly you are wanting to do with the data.
Mike...
12-24-2008 12:55 AM
Everything Mike wrote is true. 🙂
mathan wrote:What my problem was when i used this array in another vi through connector panes, all the rows in the array got the width of the maximum size row and are filled with zeroes.
The array you are showing in the picture cannot be numeric, it is probably an array of strings. As you can see from the background, all colums are the same lenght (look for the background shading), so your marked elements must contains string of lenght zero. Sending an array through a connector pane does not change anything, so you must be doing more than that. Possibly, you converted the string aray into a numeric data type somewhere.
12-24-2008 01:06 AM
Dear all,
Everything altenbach wrote is true. 🙂
altenbach wrote:The array you are showing in the picture cannot be numeric, it is probably an array of strings...........
..........you must be doing more than that. Possibly, you converted the string aray into a numeric data type somewhere.
Great thinking altenbach. All the things you mentioned are right. Really appreciate your indepth knowledge and experience in LabVIEW.
12-24-2008 01:28 AM
12-30-2008 12:36 AM
Dear all,
Initially, i have a 2D array that was read from a text file, with some elements filled with zeroes (as mikeporter told - LV does not support sparse arrays. All rows have the same number of columns and all columns have the same number of rows). Refer the picture from the first post.
Using "array size", length of each rows in the array gives correct number excluding the elements "00". Actually, i have to pass this array and also the length of the array to a dll input. Everything worked perfectly.
What my problem is - The dll outputs a 2D array and i have to write this array output to a text file. Again the elements are filled with zeroes. How to eliminate these unwanted zeroes? How to delete particular elements from an array?
see the attached vi. I have used "array subset" but its not giving what i wanted. Also i tried "Delete from Array", its also not worked out.
12-30-2008 01:28 AM - edited 12-30-2008 01:29 AM
Your VI makes no sense. Why not autoidenxing? Why "delete from array"?
Here's one simple possibility (just write the resulting string to a file).

12-30-2008 06:42 AM
Dear Altenbach,
Your solution worked perfect. Thanks a lot. But isn't it possible to display the array in hexadecimal numbers in the required format instead of strings?
12-30-2008 06:51 AM
mathan wrote:... But isn't it possible to display the array in hexadecimal numbers in the required format instead of strings?
Take another look at Mike porter's reply about sparse arrays.
LV wants all 2d arrays to be rectangular i.e. all rows have the smae number of collumns.
If the 2d array is numeric, then there has to be a number in every cell. With string arrays you can have an empty string in one of the cells. The other approach (again see Mike's reply) is to use a cluster of arrays where each array is one of your rows. In this approach, each of your arrays( a row) can have unique sizes. Please note that using a cluster means you have to work with a limited number of rows since you have to define this at edit time.
I hope this helps,
Ben
12-30-2008 07:07 AM
Ben wrote:
The other approach (again see Mike's reply) is to use a cluster of arrays where each array is one of your rows. In this approach, each of your arrays( a row) can have unique sizes. Please note that using a cluster means you have to work with a limited number of rows since you have to define this at edit time.
Thanks Ben,
Just now clearly understood the full meaning of that approach by your post. Thanks a lot. I am designing some test utilities. As of now i closed it up using altenbach's method. Thanks for all your suggestions.