Question: QUESTION 2 : [ 3 0 ] A geometric series with n number of terms is defined as follows, where a is the first term

QUESTION 2: [30] A geometric series with n number of terms is defined as follows, where a is the first
term of the series, and r is the common ratio:
a,ar,ar2,ar3dotsarn-1
Create a local function at the end of the script named "geoseries". Assume a=r. "geoseries" function
has two outputs: (1) all the elements in a geometric series and (2) its sum. Your function will receive two
integer arguments. The first input specifies the initial value of the series (i.e. a) and the second input
specifies the number of terms in the series (i.e.n). You should include a comment section in your script
that describes the function. For example, in the Command Window, when the function "geoseries" is
called:
[output, sum]= geoseries (2,4)
output =
2,4,8,16
sum =
30
because 2+4+8+16
In vour script, test your function by writing a script that prompts the user for the input values using the
"input" function in MATLAB so that MATLAB will display the following:
Enter the initial value: 2
Enter the number of terms: 4
(red text indicates what the user will enter)
You should use one of the output statements discussed in the lecture to output the sum of the series:
The sum is: 30
You should test your function by inputting different input values to ensure that the function works properly.
Note: any MATLAB built-in functions (except sum()) and conditional statements (if-else
statement, for and while loops) are NOT allowed in this question.
 QUESTION 2: [30] A geometric series with n number of terms

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!