LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Choosing every n-th element of string array

Solved!
Go to solution

Hi,
I want to load into memory series of thermograms. The thing is I can get all of them (180) read although I need to improve/compare the results of FFT performed on them - so I want to 'change the sampling frequency' so I will load every 2nd, 3rd, 4th,.. 9th termogram. That would be chosen by the user. 


How am I supposed to alter the 1d array of strings with paths so only every n-th element will be in output array? I attached the VI that gets coma as the first array element. 

Michał

0 Kudos
Message 1 of 5
(3,967 Views)
Solution
Accepted by topic author thor91

If I understand the question properly, you want a way to take a 1D array and get every Nth element as a second 1D array.  There are many ways to do this, but one is to reshape the 1D array into a 2D array with N columns and use the contents of the first column (which will be 0, N, 2N, etc.).  [You need to be sure N is between 1 and the size of the Array, of course ...].

Every Nth Element.png

Bob Schor

0 Kudos
Message 2 of 5
(3,950 Views)

@Bob_Schor wrote:

If I understand the question properly, you want a way to take a 1D array and get every Nth element as a second 1D array. 


One problem with the reshape function is that it allocates another array where most of it is thrown away right afterwards. I would probably go with something similar to this code.

 

 

 

 

 

0 Kudos
Message 3 of 5
(3,925 Views)

With the new conditional tunnel, wouldn't it be easier to just feed the remainder into an Equals 0? and use that true/false as the tunnel condition to build the array that way instead of using multiple array functions to get the same result?

0 Kudos
Message 4 of 5
(3,913 Views)

@natasftw wrote:

With the new conditional tunnel, wouldn't it be easier to just feed the remainder into an Equals 0? and use that true/false as the tunnel condition to build the array that way instead of using multiple array functions to get the same result?


The explicit method is more efficient because the size of the output is exactly defined. With the conditional tunnel, the final number of elements is not known and thus cannot be correctly allocated in one operation.

 

Also, a Q&R operation is more expensive than a multipliucation. You could even do an addition in a shift register instead.

0 Kudos
Message 5 of 5
(3,898 Views)