LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use column in 2d array as page number for 3d array

I have a 2D array coming from a database containing (I simplify a bit for this example)

column 0: plot number

column 1: x values

column 2: corresponding y values

 

to be able to process everything and later put it in a graph, i would like to convert it into a 3d array where the page number is the plot number (so column 0) from my original array. I tried two different approaches you can see in the attachment, both give unwanted results:

1. the resulting array contains two pages with only x2 and y2 for each plot

2. the resulting array contains two pages with only x1 and y1 for each plot

 

What am i doing wrong here?

 

As a second difficulty the order in the example 2d array is logical (x1 of plot 1, x1 of plot 2, x2 of plot1.....) .

The order in the actual array might just as well be as the example in the second attachment

 

Thanks!

Download All
0 Kudos
Message 1 of 12
(3,255 Views)

I understand converting column 0 to the plot number, but what will the (2-D) data look like for each page?

 

 

Message Edited by vt92 on 03-11-2009 08:13 AM
>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 2 of 12
(3,228 Views)

I hope the attached picture clarifies what result I want.

The array on top shows the initial array, the two at the bottom show page 0 and 1  of the result array.

 

 

 

 

 

Edit: made the picture a bit more clear

Message Edited by _blackadder_ on 03-11-2009 08:43 AM
0 Kudos
Message 3 of 12
(3,215 Views)

A couple of key questions:

 

  • Are the x/y values in sequential order? Your "bad" order example seems to imply that the x and y values come in sequential order, though the values from one plot can be intermingled with the values from another.
  • Does each plot have the same number of rows (x/y) pairs?

I ask these to determine how much the resultant VI can be simplified based on certain working restrictions, or whether no such restrictions can exist.
0 Kudos
Message 4 of 12
(3,185 Views)

No to both questions, the points of the plots can come in any order possible and not every plot has the same amount of points...

(I guess this doesn't really simplify my problem Smiley Indifferent )

Message Edited by _blackadder_ on 03-11-2009 10:32 AM
0 Kudos
Message 5 of 12
(3,178 Views)
Will there always be either a 0 or 1 in the first column?  I'm having a lot of trouble making this work for any number.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 12
(3,175 Views)

Attached (LV 8.0) is something I quickly whipped up using the above 2 assumptions as being true. I did not fully test this, so be sure to put it through its paces. Smiley Wink

 

Your solutions centered on using Insert Into Array. The reason this won't work is because your first x/y pair could be from plot 1 (the second page). But, you cannot insert a second page into an empty array.  I opted for pre-creating the 3D array and then using Replace Array Subset. 

 

OK, I posted this before I got the notification that you answered my questions. Given that, then how is one supposed to know the order of the X/Y pairs? Obviously, your example used strings for demonstration. Presumably the real values will be numbers. In this case, how is one supposed to know where to place the new X/Y pair?

 

Corollary: Arrays must be rectangular. This means that if plot 0 has 3 XY pairs, but plot 1 has 5, then the 3D array MUST have 5 rows for each page. This means you will have empty rows on page 0. Given this, you are better off creating an array of clusters. Each cluster would contain your XY pairs as a 2D array, and each one can have different number of rows, as shown in this figure:

Message Edited by smercurio_fc on 03-11-2009 10:43 AM
Download All
Message 7 of 12
(3,174 Views)

Looks like a good solution. Didn't think of creating an empty set at first.

In fact, this still works if my plots have different amounts of points right?

The smaller plots are just padded but I don't think there's any way around that with an array.

0 Kudos
Message 8 of 12
(3,167 Views)
Which solution? The VI I posted, or the array of clusters? If you're referring to the VI, then no, that won't work. As I indicated, I wrote that based on the assumptions being true. Since you said those assumptions were not, then the VI won't work. For the array of clusters the 2D array of x/y pairs is "encapsulated" by a cluster, which is why you can have a different number of rows for each instance. However, it's still not clear how one is supposed to know how to order the XY pairs since you said they can come in any order. It seems to me that this is your main problem, and until you can say how one is supposed to know how to order the XY pairs, then I don't see how you can come up with a solution.
Message Edited by smercurio_fc on 03-11-2009 10:54 AM
0 Kudos
Message 9 of 12
(3,158 Views)

Yes, i thought of that, but that would mean every time i want to add a point I have to extract this 2d array from the cluster, add the point and then replace the entire original 2d array with the new one.

It seems it would be better to just have some of the plots padded and take care of that later when I'm converting it to real plots.

 

(indeed the x and y are numbers in the end making it easy to sort them correctly, that wouldn't really be a problem)

0 Kudos
Message 10 of 12
(3,157 Views)