LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array index using formula node

Solved!
Go to solution

Hello,

 

I'm new to labview....

I'm trying to create a vi that takes a number n, and outputs all of the prime numbers from 0 to n (i.e. including 1).

My approach to do it is using a formula node, but I can't figure out how to index the array or to output every prime number.

It seems that my indexing algorithm works fine, but I'm just pushing it to the array as an element.

It'll will be great if anyone could take a look at my vi, and give me a hint on how to index properly.

 

Thank you,

 

AA

 

0 Kudos
Message 1 of 5
(11,631 Views)

Why not do this in pure LabVIEW code?

 

You are only putting in a single number, and outputing scalar numbers of prime and index.  If you want to search for more numbers, you are going to need to put this whole thing in a while loop and feeding multiple numbers in at number an autoindexing output of your 1-D array into a 2-D array at the tunnel of your loop.

0 Kudos
Message 2 of 5
(11,610 Views)

In the end I've created a hybrid of code and labview. It's far from being the most efficient code, but it works.

I thought, probably wrong though, that doing it with pure LabVIEW code will complicate things. I don't control it very well yet, and I didn't know how to set up counters/index.

Message Edited by amitalon on 04-14-2010 08:14 PM
Message Edited by amitalon on 04-14-2010 08:15 PM
0 Kudos
Message 3 of 5
(11,605 Views)
Solution
Accepted by topic author simply_me

your output needs to be an array, and to index it use prime[index]

also you need to declare index and prime[]

 

prime numbers.pngprime fp.jpg

Message Edited by Rodrigo Cuenca on 04-14-2010 08:25 PM
Rodrigo Cuenca
www.cidesi.com

Message 4 of 5
(11,599 Views)
Ohh.... I didnt know you can define arrays in the formula node.
0 Kudos
Message 5 of 5
(11,594 Views)