LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I index the array at multiple locations without using loops?

I have an array of size Nx1 and I would like to return a subset of size Mx1 but Mx1 is not a contiguous subarray of the original set. Is there a way to do this without looping through my set of M and plucking out the points one by one?

 

Thanks!

 

Steven 

0 Kudos
Message 1 of 4
(2,775 Views)

What is it about the elements that makes them a set of the array Mx1? Maybe if I know that I can suggest a method to do what you want without looping through and picking points one by one.

0 Kudos
Message 2 of 4
(2,768 Views)

So I have a vector X(N) and I want to multiply say every other element [e.g. X(1,3,5,7,9,...,N) ] by another vector which I obtain in a similar fashion. 

 

In MATLAB, my code would look something like this.

 

index1 = [1:K:N];     

index2 = [1:L:M]; 

X(index1)*X(index2); 

 

where index1 and index 2 are of the same total length but just represent different indices within X. 

 

Thanks very much!

0 Kudos
Message 3 of 4
(2,765 Views)

What is wrong with looping?

 

If the indices are every other one like you have shown, then you could use decimate array.

Message 4 of 4
(2,760 Views)