LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build array with certain value using case structure

Hey Guy's 

I want to iteratively fill an array of random integers between 0 and 100 in ascending order every 1 second then add a delay routine after which if no new value is displayed in the table the program displays a string indicator " elapsed time " .

Well i done the true case but i failed the rest ! 😕 can't find how to do it !

any idea !?

 

 

That's the True case:

True Case

But i don't know how to do the False Case:

False Case

0 Kudos
Message 1 of 15
(4,149 Views)
Just wire the array through in the false case.
0 Kudos
Message 2 of 15
(4,142 Views)

In addition To Dennis's comment:

 

  • your lower shift regsiter should be initialize with -inf, else you might get unexpected results on subsequent runs because the shift register will remember the last value from the previous run.
  • It is significantty more efficient to add elements to the end of an existing array. You can reverse it for display.
  • There should also be a small delay (even 0ms) when the false case executes.
  • The array indicator should be outside the case. RIght now it won't update until the first time the case is true, possibly confusing the operator (What if the case never turns true?). It is also less efficient to hide indicators and controls in innermost structures.
  • Making the 1D array vertical on the front panel makes it more compact and easier to follow.
  • Your stop button should be on the visible part of the front panel. How else do you stop the VI?
0 Kudos
Message 3 of 15
(4,127 Views)

You aren't creating integers, you are creating an array of floating point values.  If you want an integer between 0 and 100, you should multiply the random number by 101 and round down.

 

What happens if your very first number is picked as 100?  There are no integers larger than that.

 

You said you want it to be ascending numbers, but if you are getting a larger number, you are putting it at the front of the array,  Your resulting array will be descending numbers.

0 Kudos
Message 4 of 15
(4,117 Views)

I want it to put in the array just the number that is great than the last number and ignore the number that is less than the previous number ! how do i wire the shift register ? 

0 Kudos
Message 5 of 15
(4,096 Views)

here how i want it:

        - if the number generated is greater than the previous number, put it in the array 

 

0 Kudos
Message 6 of 15
(4,091 Views)

here how i want it:

        - if the number generated is greater than the previous number, put it in the array 

        - else if the number is less than the previous number ignore it !

i want to know how to wire the shift register !

0 Kudos
Message 7 of 15
(4,087 Views)

When you say "previous number", do you mean the last number that was put in the array or the last number that was generated?

 

This snippet is based on the "previous number generated".  The FALSE case just wires the array straight through.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 15
(4,061 Views)

It's ok it work ! but i won't to add a delay if no number is added to the array within 5second the program print time elapsed !? how to do it ? 

 

 

0 Kudos
Message 9 of 15
(4,050 Views)

@MedAmine_07 wrote:

but i won't to add a delay if no number is added to the array within 5second the program print time elapsed !?


I have no clue what you are asking for here.  What do you want with the 5 seconds?



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 15
(4,029 Views)