LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

generate array from string

Hello,

 

In my attached array, I wanted to generate another array that just contains the numeric LO Freq enteries.

 

This is my original array:

Temp:RM LO Freq: 136
Temp:RM LO Freq: 136
Temp:RM LO Freq: 136
Temp:RM LO Freq: 136
Temp:RM LO Freq: 136
Temp:RM LO Freq: 136
Temp:RM LO Freq: 155
Temp:RM LO Freq: 155
Temp:RM LO Freq: 155
Temp:RM LO Freq: 155
Temp:RM LO Freq: 155
Temp:RM LO Freq: 155
Temp:RM LO Freq: 155

 

I wanted to generate the array:

136

155

 

I was already able to extract the LO Freq numeric values, but need some help to generate the final array together with the array position entry where the LO Freq changes value (in the above case entry 6)

 

Thanks,

hiNi.

Download All
0 Kudos
Message 1 of 5
(2,556 Views)

Do you only want to add to the array when the value changes?  OR do you want to only add a value if it wasn't already in the array.

 

136

155

136

 

If you only want to add when changed, use a for loop to check the current value from your string array with the last value added to your output array.  If it's different, use "insert into array.vi"  

 

If you want to avoid duplicates (avoiding the example above) you can use "Search 1D array" to determine if the value has ever been entered in the array.

0 Kudos
Message 2 of 5
(2,550 Views)

Hello,

 

I am able to generate the frequency array, but I am having a little trouble implementing the search array to remove the duplicate enteries.  Also, how do I return the array with the position of the frequency change?

Download All
0 Kudos
Message 3 of 5
(2,533 Views)

I have an older version of labview so I'll try to help with words.

 

"I am able to generate the frequency array"

 

Which array? the one which contains all the values from the string array or the final array you were trying to get?

 

Using a for loop to iterate through the full array, compare the current value with the previous one (a shift register can be used to hold the value from the previous iteration).  If it's new, use "insert into array.vi".

 

The current step of the for loop is the position at which the change occured.   i

 

You can place these values into their own array if you want.

0 Kudos
Message 4 of 5
(2,529 Views)

Something crude like this could work.

 

I'm sure there is a more elaborate way to do this somewhere.

Message 5 of 5
(2,522 Views)