Short out an array according to the elements of another array
#1
Posted 15 June 2012 - 06:21 AM
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
#2
Posted 15 June 2012 - 07:43 AM
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??
#3
Posted 15 June 2012 - 08:00 AM
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.
#4
Posted 15 June 2012 - 09:40 AM
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.
Attached Files
Edited by Ano Ano, 15 June 2012 - 09:41 AM.
#5
Posted 15 June 2012 - 10:19 AM
I was so hoping that I could be the first person to respond to this.[...]
Any suggestions on who to do it?
Thank you in advance
Resistance is Mandatory
#6
Posted 15 June 2012 - 11:41 AM
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.
Rolf Kalbermatter
CIT Engineering Netherlands
A division of Test & Measurement Solutions
#7
Posted 03 July 2012 - 08:39 PM
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













