LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting 2D array using formula node

Solved!
Go to solution
Highlighted

Hi

 

  • What l am trying to do is sort numbers into groups.

 

  • A group consists of numbers that either are equal or step up or down by one value. Each group is to be assigned to one column. E.g. Column O of input test array would consist of 5, 4, and 3 but not 9 and 10. These values belong in Column 1. However if the adjacent cell in Column was not empty then 9 and 10 would stay in Column 0

 

  1. To better understand formula node programming l went to 1D. I found that each cell is not treated individually with my code.
  • The orange final input test array is the type of data l would like to sort in a 2D array that ends up the same size array.

 

  • In the code l have provided my aim to compare each cell in each column row by row to determine if a cell is equal e.g. a = b, a+1 = b or a-1 = b if so then these values are in the correct column. If not a sort must be performed to place a value in it's correct column.

 

This is my first go with formula node and l has to admit looking at other examples l have found a little confusing how a result was obtained. I prefer to do all programming in labview instead of going to another program to obtain the result l am after.I have tried array programming only for this problem and found it to be getting very complicated and large so l stopped. To me the formula node route should be simpler and more compact. My last resort is to use Excel but l still hope to do all programming in Labview so l end up with a more dynamic program.

 

Regards

 

Michael

0 Kudos
Message 1 of 11
(1,794 Views)
Highlighted

I think you should post the expected 2D Array result for people to better undrestand you requirements.


CLA CTAChampion
Subscribe to our Test Automation user group: UK Test Automation Group
0 Kudos
Message 2 of 11
(1,774 Views)
Highlighted

Hi

 

Thank you for your interest.

 

I have provided you a vi that illustrates the solution l am after.

 

I could not get the pre and post increments to work ++ or -- and a number of other operators. My main problem was why a number of operators would not work. However simple formulas are easy.

 

I would like the code to examine cell by cell.

 

I found another example (quick sort vi) that uses partition to me it seems to be C code. It did not help with my understanding however it seems to be able to view cell by cell. Where as with my 1D array I found one cell that triggered an if statement placed 65 in all the remaining cells. I can see why this happened but l was not able to produce code to examine cell  by cell values after the trigger point. This is how the 1D sort vi performs that is provided by Labview so l assume it is based on text code.

 

I hope my response clarifies my problem

 

Regards

 

Michael

 

0 Kudos
Message 3 of 11
(1,750 Views)
Highlighted

I hope this is what you are looking for. Sorry the diagram is a bit cluttered!

sort 2d array.png


CLA CTAChampion
Subscribe to our Test Automation user group: UK Test Automation Group
0 Kudos
Message 4 of 11
(1,734 Views)
Highlighted

Typically we don't like to answer questions with limitating conditions (using a formula node). A graphical solution seems much more appropriate here, after all, this is a LabVIEW forum!

 

Do you really want to insist on a "formula node" solution? Why? Why do you even use LabVIEW then?


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 11
(1,715 Views)
Highlighted
Solution
Accepted by topic author wetland

Hi

 

You are bloody brilliant...........!!!!!!!!!!!!!!

 

I just could not get it to would on multiple occasions using arrays, l have actually been on it for weeks. I never thought of the way you have solved this problem.

 

I hate excel and text programming. I am graphically minded that is why l like labview.

 

I did get a solution in Excel yesterday but your solution is far better than what l came up with

 

I very grateful

 

Thank you

 

Michael

0 Kudos
Message 6 of 11
(1,704 Views)
Highlighted

Michael,

 

The courteous thing to do is to mark the post which helped you to fix your problem as the solution, probably the .aCe. post in this case.  You first will need to go to the Options link on the right side and unmark your post as the solution and then mark the appropriate one.

 

Marking your own post as the solution does not help someone else with a similar problem to find the solution quickly.

 

Lynn

Message 7 of 11
(1,698 Views)
Highlighted

Hi Lynn

 

Yes it was aCe. It was a brilliant solution. I had the same ideas but was working at it on the right side of the array and ended up with a mountain of code. Just did not come up with an idea to do it from the left side of the array. In fact this is the first time l have found out that you could solve a sorting problem in this way.

 

Now what is this options mark all about? Are you able to provide more details? Is it normal to report to a moderator or highlight. I am very happy with the solution. I have only used the forum about two times may 3 to solve a programming problem.

 

By the way the only other array problem l have had on this forum is one that you had provided a solution. I understand how aCe solution has worked but the one you provided me in the past was also brilliant but l have not yet understand how it completely operates. I am just so happy that it works

 

So l am very grateful for both you and aCe

 

Regards

 

Michael

 

 

0 Kudos
Message 8 of 11
(1,692 Views)
Highlighted

Your own message that you marked as the solution.  There is a link called "Options" to the upper right of that.  Pick it.  Then pick "Unmark as Solution".

 

Then you can mark Ace's message as the solution.

0 Kudos
Message 9 of 11
(1,689 Views)
Highlighted

Hi RavensFan

 

I see the Options link.

 

When pressed these are the options l have

Mark as New

Bookmark

Subscribe

Subscribe to RSS feed

Highlight

Print

Email to a friend

Report to Moderator

 

I do not see Unmark as Solution. I did pick a button about solution that l do not see any more. I did this on my first response after first viewing the solution by aCe when l stated the solution was brilliant. So l believe l have done that part already.

 

It seems to me l have not marked aCe array as the solution. Do you use the message tag for that?

 

Regards

 

Michael

0 Kudos
Message 10 of 11
(1,682 Views)