11-26-2014 04:28 PM
I need to change the following array to be sorted in numeric order (right to left and from top to bottom)
if you can't see the image the array is as follows
{[0,1,17,2,3,20,4,5,6,7,8,26,27,14,29,15]
[0,9,0,10,19,0,21,11,12,13,25,0,0,28,0,30]
[0,16,0,18,0,0,33,22,23,24,35,0,0,36,0,37]
[0,31,0,32,0,0,0,34,0,0,0,0,0,0,0,0]} (sorry for those math people out there for the formatting)...
I need the array above to turn out as such
{[0,1,0,2,3,0,4,5,6,7,8,0,0,0,0,0]
[0,9,0,10,0,0,0,11,12,13,0,0,0,14,0,15]
[0,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
[0,31,0,32,0,0,33,34,0,0,35,0,0,36,0,37]}
Does anyone have some idea what I could do in LabVIEW that can sort this out?
Regards,
Mark
Solved! Go to Solution.
11-26-2014 04:43 PM - edited 11-26-2014 04:44 PM
Try the attached code. Not sure if this would achieve your goal
.
11-26-2014 05:13 PM
What are you trying to do? How does the new array relate to the old one?
11-27-2014 02:04 AM
mark.eckhoff wrote:
{[ 0, 1,17, 2, 3,20, 4, 5, 6, 7, 8,26,27,14,29,15]
[ 0, 9, 0,10,19, 0,21,11,12,13,25, 0, 0,28, 0,30]
[ 0,16, 0,18, 0, 0,33,22,23,24,35, 0, 0,36, 0,37]
[ 0,31, 0,32, 0, 0, 0,34, 0, 0, 0, 0, 0, 0, 0, 0]}
I need the array above to turn out as such:
{[ 0, 1, 0, 2, 3, 0, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0]
[ 0, 9, 0,10, 0, 0, 0,11,12,13, 0, 0, 0,14, 0,15]
[ 0,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
[ 0,31, 0,32, 0, 0,33,34, 0, 0,35, 0, 0,36, 0,37]}
This result does not look like it is "sorted in numeric order (right to left and from top to bottom)" in any recognizable way. It semes that the zeroes have a special meaning such that some out-of-order elements get replaced by zero and then inserted into the same column, but in a later row. The insert pont seems to be picked such that the row is sorted.
11-27-2014 03:51 AM
If you can explain the logic of how this is supposed to work we might be able to help you.
/Y
11-27-2014 11:02 PM
Hi Mark,
I dont know whether you have tried to solve this or not, but I did some practise on this. Please find the attachment.
I have tested it with your example only so not sure about its full functionality.
If you have any question just reply me.
Kudos are always Welcome..... 🙂
11-28-2014 02:39 AM
@Vinal_G wrote:
I have tested it with your example only so not sure about its full functionality.
Please add the quoted sample data to the control, make current values default, save the VI and attach it once more.
11-28-2014 02:45 AM
Done.
11-28-2014 03:33 AM
But what does it do? It's very convoluted and no comments.
11-28-2014 11:45 AM
Sorry Everyone,
I haven't had any time yet to test the solutions quite yet due to the holiday and I don't have access to my LV project and machine so I won't be able to check back in with you guys until Monday morning.
Regards,
Mark