Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions