# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## control array Elements

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?

Message 1 of 9
(296 Views)

## Re: control array Elements

I looked at you block diagram.

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

So I stopped looking at it.

Message 2 of 9
(274 Views)
Solution
Accepted by topic author medum

## Re: control array Elements

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
(248 Views)

## Re: control array Elements

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.:

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

Message 4 of 9
(215 Views)

## Re: control array Elements

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

What can I do?

Message 5 of 9
(181 Views)

## Re: control array Elements

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
Message 6 of 9
(155 Views)

## Re: control array Elements

@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).

Message 7 of 9
(142 Views)

## Re: control array Elements

How is it look like?

Message 8 of 9
(119 Views)

## Re: control array Elements

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
Message 9 of 9
(107 Views)