Ano Ano Posted June 15, 2012 Report Share Posted June 15, 2012 Hello, I have the following situation: First array: 1 2 3 4 5 6 7 8 9 10 Second Array: 3 0.01 6 0.08 7 0.03 and I want to create a Third array: 1 2 3 0.01 4 5 6 0.08 7 0.03 8 9 10 Any suggestions on who to do it? Thank you in advance Quote Link to comment
Maite Posted June 15, 2012 Report Share Posted June 15, 2012 When you say 1 2 3 ... and 3 0.01 6 0.08 Do you mean that in the index 3 of the first array do you want to place the index 3 of the second one. Or for the value 3 of the first array you want to place the index 3 of the second?? Quote Link to comment
Aristos Queue Posted June 15, 2012 Report Share Posted June 15, 2012 Ano Ano: These sorts of questions always work best if you can post your best attempt so far and let us help you fix it. If nothing else, go ahead and build the front panel that you want so that everyone is clear what data types you're trying to build up. This sounds like a homework question, and the community will help, but it won't write it for you. Give us something to start with and then we can point you the right way. 1 Quote Link to comment
Ano Ano Posted June 15, 2012 Author Report Share Posted June 15, 2012 (edited) Hello, Thank you for your prompt reply. Maite: I want to take the value from the second column of the second array and place it in a second column on the first array at the same location as it was in the second array. Aristos Queue: No this is not a homework. I am too old for school & University:P. It is just that the mind tends to stop when it encounters a problem on simple logic:P I am attaching my code, which seems to do the job (finally). Please have a look and if there is any better way of doing it please suggest it! Thank you in advance. Array Sorting.vi Edited June 15, 2012 by Ano Ano Quote Link to comment
jcarmody Posted June 15, 2012 Report Share Posted June 15, 2012 [...] Any suggestions on who to do it? Thank you in advance I was so hoping that I could be the first person to respond to this. Quote Link to comment
Rolf Kalbermatter Posted June 15, 2012 Report Share Posted June 15, 2012 Hello, Thank you for your prompt reply. Maite: I want to take the value from the second column of the second array and place it in a second column on the first array at the same location as it was in the second array. Aristos Queue: No this is not a homework. I am too old for school & University:P. It is just that the mind tends to stop when it encounters a problem on simple logic:P I am attaching my code, which seems to do the job (finally). Please have a look and if there is any better way of doing it please suggest it! Thank you in advance. Why would you use string arrays, if the example you gave in your first post only contains numbers? Also I think your data structure design is highly flawed, if the data in the first post is all you want to sort. What you should look at is to use a 1D array of integers for your first array and an 1D array of cluster containing an integer and a float for your second array and the result. Quote Link to comment
Slacter Posted July 3, 2012 Report Share Posted July 3, 2012 The sample assumes that the Data Array Col 1 values are found in the same order that they would appear in the Main Array. Try swapping your 6 and 7 position and you'll find the 0.08 and 0.03 don't populate correctly. How would you handle duplicate Data Array values in Col 1? The existing code uses only the first found and ignores the rest. Would you want to change to the last found, or do you need to keep track of all instances? In case you're up for the challenge, the intended functionality can be obtained using the following: 2 - Index Arrays 1 - Search 1D Array 1 - Replace Array Subset 1 - For Loop 1 - Case Structure FYI: The functionality using the above would use the last found occurrence and keep only that value. If data loss is not desired, then a little rethinking is in order. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.