Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 4: User-defined functions (19 points) The Fibonacci sequence is characterized by the set of numbers beginning with Fi 1, F2 1, and every following

image text in transcribed
image text in transcribed
Part 4: User-defined functions (19 points) The Fibonacci sequence is characterized by the set of numbers beginning with Fi 1, F2 1, and every following number is the sum of the previous two numbers: F F-2+ F-1. Create a user-defined function that calculates a sequence similar to the Fibonacci sequence using any two starting numbers-F-a, F2 = b,R-Fn-2 + Fn-1-and returns the nth number in the sequence. Before you begin writing your function, take some time to answer these questions. All answers should be written in the appropriate space in the table on the last page. What is the name of your function going to be? NOTE: The rules for naming functions are the same as naming scripts and variables in MATLAB Write a short line stating the purpose of your function. What input arguments do you need in order to transfer data into the function? Write out each input argument; its name and description. Think about what data you need from the user in order to perform the appropriate calculations. DO NOT use the input) function in MATLAB for this part. What output arguments do you need in order to transfer data out of the function? Write out each output argument; its name and description. Think about what information/data the user wants from the calculations. Write down the function definition line for your function using your answers in parts 1, 2, and 3 1. 2. 3. 4. 5. 6. Complete your function body by translating the following steps into MATLAB code: if the nth number is 1 if the nth number is 2 anything else return Fi return F2 for the number of desired terms starting at 3 return Fo Fnz+ Fnl

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

1. Practice giving the test before you actually use it.

Answered: 1 week ago

Question

2. How should this be dealt with by the organisation?

Answered: 1 week ago

Question

explain what is meant by the term fair dismissal

Answered: 1 week ago