LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to append and sort 2D array?

Dear all,
 
I have six 2D arrays, every 2D array conresponding X and Y value, Now I want to append these six 2D arrays together, and then reorder them by the increasing order of X value.
 
I try to use "build array" to append them, but it looks only can use for 1D array, so how can I append these six 2D arrays? is it the block "Insert into array"?
 
and after that how to recorder the whole 2D arrays? I only found "sort 1D array", but how to sort 2D array?
 
Thank you for any help!
 
Jing
0 Kudos
Message 1 of 19
(5,604 Views)
Hi

Build array is the correct function to use if you want to append arrays. You might have to right-click the build array block and activate "Concatenate Inputs", else the output will be 3D.
Sorting only works for 1D arrays, you can for instance create an array of clusters with x and y values (x must be the first element in the cluster if you want to sort by x) and sort this.

Hope this helps,
Daniel

0 Kudos
Message 2 of 19
(5,598 Views)
Hi jing,
see the attached example. First i create two 2d array, then i build a new one and then i sort them.
Mike
Message 3 of 19
(5,597 Views)
Thank you Daniel for quickly answer! It is very helpful, Thank  you again!
 
 
Jing


帖子被菁菁在06-03-2008 03:42 AM时编辑过了
0 Kudos
Message 4 of 19
(5,590 Views)
Thank you Mike for your quickly solusion!
 
 and If I want to append six 2D arrays just to large the input of " build array" to six, right? like attached picture.
 
BTW: you are really early today!!!!!!
 
Jing
0 Kudos
Message 5 of 19
(5,587 Views)

Hi jing,

yes enlarge the "build array" function to six. Notice that it could be that your 2d arrays are transposed!

Mike

0 Kudos
Message 6 of 19
(5,585 Views)

Hi jing,

you can also do it in a loop.

Mike

Message 7 of 19
(5,582 Views)
Hi Mike thank you again
 
Now I met a problem again, after getting the sorted 2D array ( one array corresponding to X and the other corresponding Y value) , then I want to get more accurate Y value for every X value point.
 
I want to do it in this way, for example:
X value:0   1   2   3   4   5   6   7   8   9  
Y value:8   5   4   6   4   7   6   1   3   9 
for the X value 5,  I want to add the all Y value corresponding X value before 4 and after 4 point to X value 5, and then divide by 9, then I can get the more accurate Y value corresponding to X value 5. the average value for X value 5 is: (5+4+6+4+7+6+1+3+9)/9
 
I expect to do this for  every X value point, then I can get more accurate Y value. Do u  have some thoughts?
 
very apprieciating for your help!
 
Jing
 
 


帖子被菁菁在06-03-2008 06:08 AM时编辑过了
0 Kudos
Message 8 of 19
(5,565 Views)

Hi jing,

see the attached picture.

Mike



Message Edited by MikeS81 on 06-03-2008 01:25 PM
Message 9 of 19
(5,559 Views)

You are always so quick!

Good for you Mike!

Jing

0 Kudos
Message 10 of 19
(5,554 Views)