キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

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 件の賞賛
メッセージ1/30
20,199件の閲覧回数

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
メッセージ2/30
20,194件の閲覧回数

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: https://learn.ni.com/learn/article/labview-tutorial 

 

 

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!"


メッセージ3/30
20,191件の閲覧回数

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
メッセージ4/30
20,187件の閲覧回数

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

https://www.ni.com/docs/en-US/bundle/labview/page/changing-data-ranges-of-numeric-controls-and-indic...

 

 

_____________________________________________________________________

---Please mark a post as a Solution if it solved your problem ---
メッセージ5/30
20,182件の閲覧回数

Oops, I think Xenox has posted in the wrong thread here スマイリー びっくりした

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


0 件の賞賛
メッセージ6/30
20,177件の閲覧回数

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 ---
メッセージ7/30
20,171件の閲覧回数

Ah sorry then, my mistake

 

-CC 

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


0 件の賞賛
メッセージ8/30
20,168件の閲覧回数

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.

メッセージ9/30
20,160件の閲覧回数
Thanks, I'll be posting my code soon
0 件の賞賛
メッセージ10/30
20,146件の閲覧回数