LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array with Fibonacci numbers

I am trying to construct a VI with one numeric input n that builds the array containing n Fibonacci number, beginning with F1.  The Fibonacci number is not defined for 0 or negative numbers.I need to  make sure that the user is not able to enter any number less than one.  And the output display should be a 2D array having a column for the values of "n" and a column for the corresponding Fibonacci number. (i.e., not two 1D arrays).

 

I know that a fibonacci numbers are the sequence of numbers, denoted by Fn.  Defined by the relation Fn=F(n-2) + F(n-1) with F1 =1 and F2 =1.

 

The following table shows the values of Fn that i need to obtain for the first few values of n (all inputs are positive values).

 

n       Fn

1        1

2        1

3        2

4        3

5        5

6        8

7       13

8       21

9       34

10     55

 

 

 

 

 

I am not sure where to even start, I'm probably making this harder than it needs to be.  If anyone could help that would be great

Many thanks

0 Kudos
Message 1 of 30
(16,762 Views)

i would suggest using n to control a for loop that calculates the Fn numbers. you may need to look up shift registers as well and a few examples. So the loop runs n times calculating the series as it goes.

 

Hope it helps 

Please remember to accept any solutions and give kudos, Thanks


LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7
Message 2 of 30
(16,757 Views)

Hi Calavan,

 

This sounds like homework! To be clear from the start, nobody here on the forums is going to code this for you, but if you have a go we can give you tips/pointers and help if you've got any specific problems

 

 

Firstly I would get to grip with the LabVIEW basics: http://www.ni.com/gettingstarted/labviewbasics/ 

 

 

When you've had a look at those tutorials then you'll see the solution to your problem is very easy to implement in LabVIEW.

 

A couple of hints:

 

  • for loops
  • numeric VIs or a formula node

-CC

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


Message 3 of 30
(16,754 Views)

my thoughts exactly, im happy to give pointers and once youve had a good go it constructive critisism. the search tool on this website is very good and so are the examples that ship with labview

 

Good Luck 

Please remember to accept any solutions and give kudos, Thanks


LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7
Message 4 of 30
(16,750 Views)

Hi,

 

right click on your numeric control --> Data Entry --> Remove the checkmark from the Use Default Limits -->  Minimum field, set the value limit (1) and select Coerce.

 

Changing Data Ranges of Numeric Controls and Indicators

http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/changing_data_ranges_of_nu/

 


_____________________________________________________________________

---Please mark a post as a Solution if it solved your problem ---
Message 5 of 30
(16,745 Views)

Oops, I think Xenox has posted in the wrong thread here Smiley Surprised

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


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

My post relates to his question:

 

"...I need to  make sure that the user is not able to enter any number less than one... "

_____________________________________________________________________

---Please mark a post as a Solution if it solved your problem ---
Message 7 of 30
(16,734 Views)

Ah sorry then, my mistake

 

-CC 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 8 of 30
(16,731 Views)

You can make this with shift register in a for loop quite easily.

 

Tip: You can pull down your shift-register node to get the value from the last round of FOR/WHILE-loop

Tip 2: You can also initialize pulled-down shift register node from last round for FOR-loops loop 0

 

This should help you enough to make your code.

Message 9 of 30
(16,723 Views)
Thanks, I'll be posting my code soon
0 Kudos
Message 10 of 30
(16,709 Views)