Question: I NEED THE MATLAB CODE FOR QUESTION 4 ONLY ! THANKS! 4. (15 pts) Let the sequence an be defined by: an+1 = ann 2

I NEED THE MATLAB CODE FOR QUESTION 4 ONLY ! THANKS!

I NEED THE MATLAB CODE FOR QUESTION 4 ONLY ! THANKS! 4.

4. (15 pts) Let the sequence an be defined by: an+1 = ann 2 n> 1 with ai = 1 Write a function called for_sequence that calculates the nth term of the sequence using a for loop. Your function should have one argument, n. The header to your function should look like: function y=for_sequence (n) where n is the number of the term in the sequence you are looking for and y is the returned term, an. Hint: You can check your code in MATLAB (NOT MATLAB GRADER) by typing the following into the command line: myresult = for_sequence (2) and check that myresult is the correct value for a2. Additionally, you can check your output from the function recursive_sequence if you have already completed it. 5. (15 pts) Let the sequence an be defined by: an+1 = ann 2 n> 1 with a = 1 Write a function called recursive_sequence that calculates the nth term of the sequence using a recursive function (see the readings for more details). Your function should have one argument, n. The header to your function should look like: function y=recursive_sequence (n) where n is the number of the term in the sequence you are looking for and y is the returned term, an. Hint: You can check your output compared with the other written function for_sequence if you have already completed it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!