LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

for loop array issue

Solved!
Go to solution

Now it means everytime the Data you are getting is the same.

its not the problem of For loop , but your algorithm 

what you are trying to do ??????

You can check your 'encrypt XETA' subvi why everytime the values generated are same ( unless you are not expecting the same values )

0 Kudos
Message 11 of 34
(1,671 Views)

It is not the encrypt vi. already used shift registers to check. I am getting the previous value.

0 Kudos
Message 12 of 34
(1,665 Views)

@kulsman wrote:

I am really new to programing in labview (started on Monday). I have been following the labview toturials online and in NI website, but I not been able to solve it.

Edit: all of the values in the array are the same.....


Of course all your values are the same, because you are always reading the same file (that operation probably belongs before the loop because the outcome will not change between iterations!) and are indexing out the same elements (with indices 2 and 3). Note that you are wiring from the inside of N, which simply returns "2" in your case, irrespective of the iteration number. If you want to index out locations that depend on the iteration number, you need to tap into the [i] terminal, not "N".

 

In any case, note that "index array" is resizeable, so you only need one instance to get two elements. Simplify!!

 

It is really impossible to debug your code from a picture, because there is simply not enough information. For example what is the datatype of the blue diagram constant wire to the file read? What is in the other case of the case structure, and what value is the boolean when you run the program? Why is Key(HEX) inside the loop? Most likely the value is constant for the duration of the loop, thus it belong outside the loop.

 

For the given reason, you should always attach your VI. Even if the subVIs are missing, it can give us much richer information to debug the situation.

0 Kudos
Message 13 of 34
(1,661 Views)

can you attach small section of code ?

Because it is not possible that if you are getting different values at every iteration of For loop from 'Encrypt XETA' vi then you are not able to get it outside the For loop with indexing enabled.

Or directly index the two outputs of 'Encrypt XETA' vi and check what do you get

0 Kudos
Message 14 of 34
(1,660 Views)

Of course all your values are the same, because you are always reading the same file (that operation probably belongs before the loop because the outcome will not change between iterations!) and are indexing out the same elements (with indices 2 and 3). Note that you are wiring from the inside of N, which simply returns "2" in your case, irrespective of the iteration number. If you want to index out locations that depend on the iteration number, you need to tap into the [i] terminal, not "N"


Christian, No excuses , I didnt pay a lot attention while replying.Smiley Embarassed

Sorry about that

 

Yeah, I thought it was just a demo

0 Kudos
Message 15 of 34
(1,653 Views)

I am not sure, if this will help here is my vi. It is saved in labview 2013

0 Kudos
Message 16 of 34
(1,653 Views)

You didnt attach Subvi and sample sound file.

Still it is very clear form

0 Kudos
Message 17 of 34
(1,646 Views)

The file I am read in is a wav file with roughly ~5000 data points. For the purpose of simplicity, I choose a C value of 2. It does not matter what C value I choose the array does not build properly. I just need to find a way to build out the array.

0 Kudos
Message 18 of 34
(1,643 Views)

@kulsman wrote:

The file I am read in is a wav file with roughly ~5000 data points. For the purpose of simplicity, I choose a C value of 2. It does not matter what C value I choose the array does not build properly. I just need to find a way to build out the array.


You are not listening. Your loop does exactly the same thing with every iteration, because nothing depends in the iteration value i.

 

What is "C"???

 

Here is code that might bring you a little bit closer to a solution. (there are still quite a few unanswered questions and problems, but this might get you started)

0 Kudos
Message 19 of 34
(1,637 Views)

you are not getting the point

In the pic you have attached you are reading the file with 5000 samples so every iteration of For loop the array is same containing 5000 elements( because you are reading the same file in loop)

Now you are interested in a fixed indexed values ( beacuse the values you are wiring to index array are constant ).

{ at this point i think you need different elements from the array every time}

So original array will always give you the same values.

and build array will act accordingly..........

0 Kudos
Message 20 of 34
(1,636 Views)