LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating an array when you have the first and last element and the step size?

I have two input strings that give me the start and finish of some data, I also have an input string for the size of the steps between the elements, is there any simple way I can use this information to create an array or am I going to have to use loops?

0 Kudos
Message 1 of 8
(3,891 Views)

Signal Processing >>> SIgnal Generation >>> Ramp Pattern.vi

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 8
(3,884 Views)

... and

Functions >> String >> String/Number Conversion >> Fract/Exp String To Number, just to convert the range and step strings to proper numbers... 😉

Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 3 of 8
(3,871 Views)

This is kind of working but I'm having problems when I get fractions , or my step size is even but I want to end on an odd number (starting from an even). Any ideas. Shall I start using loops, I'll probably try tomorrow, i'm getting tired now.

0 Kudos
Message 4 of 8
(3,852 Views)

If sleeping in it does not help, then post images of your code so far so we can comment.

 

Hint:

 

There is a quotient and remainded funtion on the Numerics pallete.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 8
(3,845 Views)

 


@Pazmush wrote:

This is kind of working but I'm having problems when I get fractions , or my step size is even but I want to end on an odd number (starting from an even). Any ideas. Shall I start using loops, I'll probably try tomorrow, i'm getting tired now.


Try changing the value of the "exclude end?" input parameter.

 

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 6 of 8
(3,843 Views)

If you have LV9 you do not need to use loops.  See the example.  You could change the controls to strings if you want, but I wouldn't.

 

Spoiler

There is nothing wrong with using loops.  This example is just for fun, the limits of LV recursion make the loop solution better.

 

About the last value, what do you expect the behavior to be?  Let's us say you have start 1.0, stop 2.1, step 0.2.  My example gives you 1.0, 1.2,...2.0.  Easy modification would include 2.2, but I don't think that makes sense.  Do you want 1.0, 1.2, ...2.0, 2.1.  Or do you want the step size adjusted and the number of steps fixed?  Too many combinations to mention.

0 Kudos
Message 7 of 8
(3,841 Views)

 


@Pazmush wrote:

... or am I going to have to use loops?


What's wrong with loops?

 

0 Kudos
Message 8 of 8
(3,825 Views)