# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## initialize indexes array

Hello!

I am new to LabView and  I am struggling with this problem for a couple of days...

I have a 2D array CH x spike_time and on each row (1D array) I need to implement a logic that requires the possibility to dynamically initialize two indexes.

To be more clear, if I indicate with CH each row of the 2D array, this is the logic I should implement on each row:

i=0;

while i <= N-min_burst_size

{  j=i+1;

while ch(j) AND ch(i)-ch(j) <= Inter_spke_interval AND j <= N-1

{j=j+1;}

if j-i+1 >= min_burst_size then save(i,j);
i=j;

}

What is the best way to implement this logic in labview?

How can I manipulate the value of the indxes i and j to initialize them as in the code? I tried to use the "Subset of Array" function in order to "cut" subset of the row starting from i and j and shift registers to pass the subset again as input of the loop, but I couldn't get to anywhere close to a solution.

If anyone could share some ideas with me or has a useful similar vi, I would be very thankful!

Thank you so much!

Message 1 of 7
(2,828 Views)

## Re: initialize indexes array

Hi MG,

when you are new to LabVIEW you should take the beginner courses offered by NI.com!

- Indexing arbitrary elements is done with IndexArray

- boolean logic is done using boolean logic functions…

- there's a palette full of comparison functions!

- "i" and "j" should be stored in shift registers of the loops

- To "define the logic" you need to explain the function save()…

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(2,815 Views)

## Re: initialize indexes array

Hi GerdW,

thank you for anwering me. Actually, I did the basic courses of NI.com, nevertheless I am stuck with this code. Sorry if my question is too naive.

My main problem is how to scan the array using indexes i and j which starting value is not the canonical 0 for a while loop or a for loop.

Which objects would you use to store i and j?

Thanks again!

MG

Message 3 of 7
(2,798 Views)

## Re: initialize indexes array

Well you could use the add function, and add 1 to i just like you did in your text version.

Message 4 of 7
(2,791 Views)
Solution
Accepted by topic author MG70

## Re: initialize indexes array

Hi MG,

I already told you to use shift registers to store I and j!

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 7
(2,783 Views)
Solution
Accepted by topic author MG70

## Re: initialize indexes array

Thank you Hoovahh and GerdW for helping me!!

Your hint allowedme to go on.
My mistake was that I kept trying using the index of the while/for loop as index of the array.

I am a beginner and I still have a lot to learn. Some things you can learn by the course, some by making mistakes, some from more experienced users like you are.

Thank you!

MG

Message 6 of 7
(2,747 Views)

## Re: initialize indexes array

@MG70 wrote:

Thank you Hoovahh and GerdW for helping me!!

No problem.  In the spirit of teaching I'd like to teach you another trick on the forums.  The large majority of us work on these forums for free, and the recognition we get partialy comes from the number of posts we are able to answer, and the number of kudos we get for helping others.  So feel free to give kudos to those that help you, and mark topics solved by a post that solves your question.

Message 7 of 7
(2,728 Views)