LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control array Elements

Solved!
Go to solution

Hello, I can successfully create an array with my step size and maximum value, but the big problem is i can see my minimum value. because is always starts from min+step size. 

min = 0

max = 3

step size = 1

 

Now i am getting: 1,2,3

but i want 0,1,2,3

 

So my min value should be always there. How can i implement that?

0 Kudos
Message 1 of 9
(871 Views)

I looked at you block diagram.

I didn't like looking at it because it's messy.

So I stopped looking at it.

0 Kudos
Message 2 of 9
(849 Views)
Solution
Accepted by medum

Hi medum,

 


@medum wrote:

So my min value should be always there. How can i implement that?


  • Then why don't you put the min value into the output array?
  • Why do you need an InsertIntoArray function to build an array? (What's the purpose of the BuildArray function?)
  • Why do you need to convert a scalar into a one-element-array before inserting into an array???
  • Why do you need to maximize the windows to fullscreen for such a simple and small VI?

 

See this simplified suggestion:

Can you provide a more complicated example with expected output? (To verify my suggestion…)

 

Btw. LabVIEW already comes with a RAMP function…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 9
(823 Views)

You can calculate the number of output elements from first principles before the loop sptarts, thus you should use a FOR loop.

 

We also have this function, of course.

 

( You also need to decide what to do if the range is not an integer multiple of the step size. (stop early, overshoot? coerce?)

 

For example what should happen for Min=2, Max=7, step=3?  ([2, 5]?, [2,5,8]?, or [2,5,7]?, for example)? What should happen in Min>Max (ramp down? empty array?)? What should happen if min=max? What should happen if the step is negative?

 

Here is something to get you started but you need to expand to deal with unexpected inputs.:

 

altenbach_1-1716912083987.png

 

 

 

In your earlier example, all inputs are integers. If this is always true, they should not be any orange anywhere!

 

0 Kudos
Message 4 of 9
(790 Views)

Yes, I want with ur example that result is [2,5]. Because max = 8. 

What can I do?

0 Kudos
Message 5 of 9
(756 Views)

Hi medum,

 


@medum wrote:

I want with ur example that result is [2,5]. Because max = 8. What can I do?


You can implement to correct algorithm according to your requirements…

 

What have you tried so far and where are you stuck (now)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(730 Views)

@medum wrote:

Yes, I want with ur example that result is [2,5]. Because max = 8. 

What can I do?


There are millions of way to do that, for example you could replace the division with  quotient&remainder.

 

You still have not told us if the values are always integers or what the final purpose of all this is. (If fractional values are allowed, you might run into other issues due to limitations of DBL representation).

0 Kudos
Message 7 of 9
(717 Views)

How is it look like?

0 Kudos
Message 8 of 9
(694 Views)

Hi medum,

 


@medum wrote:

How is it look like?


This is not an answer to all our questions…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(682 Views)