LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array with Fibonacci numbers

Kudos to y'all for navigating the fine line wire between helping and doing homework!

 

Thank you!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 11 of 30
(6,582 Views)

So i was able to get my fibonacci numbers to calculate, hoever i can not get them to dislay in a 1D array.  any sugguestions?

Thanks

0 Kudos
Message 12 of 30
(6,540 Views)

First you actually have to wire something to the array indicator.

 

Since it looks like you want to get a result from every iteration, one of your wires will also need to exit the loop as an auto-indexing tunnel.

 

Another tip is that you can probably get away with only one shift register.  If you drag the bottom border of the left hand side shift register downwards, you can get 2 values out.  One is the value put into the shift register from the previous iteration (just like normal).  The next one down below that is the data that was put into the shift register the iteration before that.

0 Kudos
Message 13 of 30
(6,534 Views)

So i miss read the problam.  It only needed to be a 1D array, so i think i got it.

0 Kudos
Message 14 of 30
(6,522 Views)

A cosmetic problem is still your representation mismatch. Since you are dealing with integers, the output array should have a blue terminal (I32). You can right-click the array terminal and either select "representation...I32" or "adapt to source".

Message 15 of 30
(6,520 Views)

Thanks, Ill fix it now

0 Kudos
Message 16 of 30
(6,522 Views)

I don't know if it may help ! but i am sharing this VI 

I am a beginner .

if you enter a number n then it will produce a fibonacci series upto that number.

ex:

if n=2

output:

1

 

if n=3

output:

0

1

1

0 Kudos
Message 17 of 30
(2,306 Views)

Hi Kushagra,

 

your implementation lacks in several items:

- way too much case structures: you only need one, when you want to use special cases for n=0,1,2!

- wrong datatypes! Why is the input set to DBL?

- Why do you use I32 for calculation? This limits your allowed input range to ~50. With U64 you can calc upto n=94…

- Why do you use a WHILE loop when the number of iterations is known? Use a FOR loop!

- Why use InsertIntoArray two times, just to prepend two array elements? Use BuildArray!

 

check.png

There are better implementations available in this forum, just search for them!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 18 of 30
(2,302 Views)
Message 19 of 30
(2,294 Views)

Here is another implementation without any case structures or BuildArrays. Works for F0, F1,... to F93

 

FibonacciSeries.png

Message 20 of 30
(2,293 Views)