From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Feedback requesting and a question regarding the extracting from the array

Solved!
Go to solution

Hello to all, thanks in advance for anyone could give me suggestions.

I attach a code I have just written, the code is a draft used to control an instrument.

For simplicity I have substituted the signal generator with the random number.

I would be interested to receive a general feedback by people more expert than me about the written code.

 

Then, a question.

The code generate an array of about 10 elements for every value of what I have called "Applied Value" in the code.

I would be interested to extract the last value of the array for every applied value.

So, for example, if I set Start = 0, Step = 0.1 and Stop = 1. The array size will be of 100, the values 

I am interested to will be only 10 to put in another array.

 

I hope that could be clear enough...

Thank you for your patience.

 

Giuseppe.

0 Kudos
Message 1 of 8
(2,908 Views)

To get the last 10 elements in an array.  Use Array Subset function.

 

(Coding tip:  Use block diagram cleanup.  You have a lot of wires running backwards through your code making it hard to read.  For example, the Divide function to the upper left looks like it has 3 inputs, and 0 outputs.)

0 Kudos
Message 2 of 8
(2,904 Views)

Dear RavensFan

thank you for your reply and in particular about the code tip.

Regarding the elements of the array, the subset function give me the last part 

of the array, for example the last 10 elements (from 90 to 100 in an array of 100), 

is it right?

In my case, for example if the array size is 100,

I am interested to extract the 10th value, the 20th, 30th and so on...that is, in the code written, the last value for every applied value.

Does it make sense?

 

Many thanks.

Giuseppe

0 Kudos
Message 3 of 8
(2,900 Views)

Hey Giuseppe,

Honestly, it's not entirely clear. Here are my thoughts (Im by no means an "expert" but take whatever you want)

 - The code is pretty difficult to follow. And I dont see anything called "Applied Value" in your code. 
 - When I run your code with the values you give, I get 11 elements in my array, not 100. I also didnt change the "time" control because I went off of the information you provided, so maybe thats the issue. 

Do you only want the last value in every array to be stored in another array? If so, and if you know that every array is going to be 10 elements, just take every 10th element and store that in another array. If they will vary in length, check the boolean value writing to the stop terminal. If it is true, take the last value in the array and write it to the secondary array that you are wanting. 

Hope this helps.

 - TXR

-TXR
***The Best way to say 'thanks' is to hit that Kudos button!***
0 Kudos
Message 4 of 8
(2,897 Views)

Dear TXRanger, first of all thenk you for your reply.

Then you are right (maybe I attached the last unsaved version on my pc) sorry for that...

I attach the right file.

With the values set as defaults, the array size should be about 100 (I think that is not exactly 100 because

the random number function does not generate exactly 10 values every second, but I am not sure...).

By the way, for every "Applidd Value" I will have 10 random numbers. 

Then the "Applied Value" changed (for example from 0,2 to 0,3) and the program generate another set of 10 random numbers.

I want to extract the last one for every "Applied Value", that means the last number before the applied value changed

toward the step forwad.

In the total array size those values should be about the 10th, 20th and so on until the 90th and 100th....

Can this be clear?

Thank you anyway for your feedback!

 

Giuseppe.

 

 

 

0 Kudos
Message 5 of 8
(2,887 Views)
Solution
Accepted by topic author GT_

Hey GiuseppeTx, 

See if this is what you are going for. I attached my editted code. 

I just added a case structure inside your while loop that should do what you want. I take the array and the length of the array and every time the while loop is about to start over (meaning the Stop terminal is True), I pass the last value in the array to a build array and out to a new array. I also have a conditional terminal setup where it will only pass data through if the case structure excutes the 'true' state, making sure that no data is passed through if the case if false. 

Hope this helps you out!

-TXR
***The Best way to say 'thanks' is to hit that Kudos button!***
Message 6 of 8
(2,854 Views)

Dear TXRanger, thank you again, great 🙂 that looks it is working very well!

Tomorrow I am going to test your solution on my measurement setup, 

but I am quite sure that it should work properly. 

How did you do this? 🙂

 

Best, Giuseppe.

0 Kudos
Message 7 of 8
(2,833 Views)

I just added a case structure inside your while loop that should do what you want. I take the array and the length of the array and every time the while loop is about to start over (meaning the Stop terminal is True), I pass the last value in the array to a build array and out to a new array. I also have a conditional terminal setup where it will only pass data through if the case structure excutes the 'true' state, making sure that no data is passed through if the case if false. 

 

You can run the code in highlight execution mode and see how it all works if you'd like as well.

-TXR
***The Best way to say 'thanks' is to hit that Kudos button!***
0 Kudos
Message 8 of 8
(2,816 Views)