Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Matlab please help solving all steps, comments needed A Fibonacci sequence

ID: 3740545 • Letter: U

Question

Using Matlab please help solving all steps, comments needed

A Fibonacci sequence is composed of elements created by adding the two previous elements. The simplest Fibonacci sequence starts with 1, 1 anod proceeds as follows: 1, 1, 2, 3, 5, 8, 13, However, a Fibonacci sequence can be created with any two starting numbers. Fibonacci sequences appear regularly in nature. For example, the shell of the chambered nautilus (Figure P9.6) grows in accordance with a Fibonacci sequence. Prompt the user to enter the first two numbers in a Fibonacci sequence and the total number of elements requested for the sequence. Find the sequence and store it in an array by using a for loop. Now plot your results ona polar graph. Use the element number for the angle and the value of the element in the sequence for the radius. Problem 9.Z(5 pts) Repeat the preceding problem, this time using a while loop

Explanation / Answer

Ques 1.

prompt = 'Enter first number in sequence : ';

% get user input

a = input(prompt);

prompt = 'Enter second number in sequence : ';

% get user input

b = input(prompt);

prompt = 'Enter the number of terms in sequence : ';

% get user input

n = input(prompt);

% store the element number

angle = [ 1 : n ];

% store the element value

radius = [1 : n];

% set the first two values of sequence

radius(1) = a;

radius(2) = b;

% generate the sequence

for i = 3 : n

   

   radius(i) = radius( i - 1 ) + radius( i - 2 );

   

end

% plot the polar plot

polarplot(angle, radius);

Ques 2.

prompt = 'Enter first number in sequence : ';

% get user input

a = input(prompt);

prompt = 'Enter second number in sequence : ';

% get user input

b = input(prompt);

prompt = 'Enter the number of terms in sequence : ';

% get user input

n = input(prompt);

% store the element number

angle = [ 1 : n ];

% store the element value

radius = [1 : n];

% set the first two values of sequence

radius(1) = a;

radius(2) = b;

i = 3;

% generate the sequence

while i <= n

   

   radius(i) = radius( i - 1 ) + radius( i - 2 );

  

   i = i + 1;

   

end

% plot the polar plot

polarplot(angle, radius);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote