LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparison output (array vs scalar)

Cheers everyone,

 

 

I would like to know how can I proceed with the following program that I am developing:

while i < Len(array) then

 

P1 = array (i)
P2 = array (i+1)

(...)

 

 

Note: P1 and P2 are the variable that I want to extract.

However, after the comparison element (which is '<') I can't connect it to anything, since this is a true/false condition. Thus, I would like to know how can I extract those two points from the array that I have. Please see the attached file. There might be present several other mistakes.

Any ideias?

Best regards,

Francisco Goulão

0 Kudos
Message 1 of 7
(2,859 Views)
You really need to take some of the free tutorials. Obviously, you can connect the result of a comparison to a case statement or select function. I don't know why you want to connect it to an index array input.
0 Kudos
Message 2 of 7
(2,853 Views)

I agree with Dennis.

 

Since the number of iterations is known before the loop starts, you need a FOR loop. No conditional terminal needed.

 

What are P1 and P2?  What is "extract"? What is a "variable"?

 

Should P1 and P2 get overwritten with each iteration? Are they processed in some way (e.g. Analog output)? Should they be build into a new array, one element per iteration? If they are just scalars, you don't even need a loop, just get the last two elements of the array and get it over with.

 

Instead of telling us how you want to do something, tell us what you are trying to do instead. What is the significance of P1 and P2? Maybe the real solution is quite different to your suggested code. 😄

 

 

0 Kudos
Message 3 of 7
(2,843 Views)

Basically, I want to perform several straight lines, composed by several points (the straight lines are the connections between the different points). However, I would like to have a program that allows me to perform as many straight lines as I want, either having 2 or 100 points.

This is the reason why I need to set the length of the array. Although in my program I just have one array, I will need to have 2 arrays: one for the x axis, and another one for the y axis. 

Thus, answering your questions (I am sorry for not having properly explained myself), P1 and P2 are the points that I want to extract from the array. Of course, since I do not know the number of points a priori, I can have P1 (...) Pn. In my opinion, this is why the while function is needed (or not, maybe I am completely wrong):

While i < len (array) Then

P1 = array (i)
P2 = array (i+1)
P3 = array (i+2)

(...) - and so on...



And then, I want to use these points to make a graph (using an equation), which means that I need to extract all of them. To do so, I think the best solution is to introduce another while, then structure inside the first one:


while 0<t<1 then

(FORMULA)

I just do not know how to extract and store all of the points to introduce them in an equation (formula). Therefore, I do not want to overwrite them, but to get every single one.

Best regards,

Francisco Goulão

 

0 Kudos
Message 4 of 7
(2,820 Views)

You already have an array of points.  So I'm not seeing the purpose of trying to break out an unknown number of them inside of a loop to just do who knows what in another loop.

 

Do you have a sample of the input array, an equation, and what you expect for an output?


GCentral
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 5 of 7
(2,807 Views)
Of course you are running out of elements when e.g. I+1 exceeds the array size.
What is x and what is y for the graph?

I think instead of long descriptions, you should show us a picture. If the input array is (5,8,12,33), what would the graph look like?
0 Kudos
Message 6 of 7
(2,805 Views)

@fgoulao wrote:

Thus, answering your questions (I am sorry for not having properly explained myself), P1 and P2 are the points that I want to extract from the array. Of course, since I do not know the number of points a priori, I can have P1 (...) Pn. In my opinion, this is why the while function is needed (or not, maybe I am completely wrong):


Yes, you are completely wrong. The size of the input array (len(array)) is obviously known before loop processing begins. Right?

 

If the loop can grow or shrink during the loop iteration (e.g. by user itereaction or from a parallel process), the control needs to be read inside the loop and the outcome would most likely be quite unpredictable and useless.

0 Kudos
Message 7 of 7
(2,795 Views)