03-09-2012 06:05 AM
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
03-09-2012 06:20 AM
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
03-09-2012 06:22 AM
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:
-CC
03-09-2012 06:25 AM
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
03-09-2012 06:33 AM
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.
http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/changing_data_ranges_of_nu/
03-09-2012 06:35 AM
Oops, I think Xenox has posted in the wrong thread here
03-09-2012 06:38 AM
My post relates to his question:
"...I need to make sure that the user is not able to enter any number less than one... "
03-09-2012 06:39 AM
Ah sorry then, my mistake
-CC
03-09-2012 06:50 AM - edited 03-09-2012 06:53 AM
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.
03-09-2012 07:02 AM