Question: Homework Assignment # 2 - Part 1 This assignment is worth 1 0 0 points and consists of two parts. This is Part 1 ,

Homework Assignment #2- Part 1
This assignment is worth 100 points and consists of two parts. This is Part 1, which covers matrix
manipulation and program flow control. Part 2 will cover user-controlled data input and output. Both Part
1 and 2 are due Tuesday, October 8th on Canvas. Code must be written in MATLAB, be well
documented, and submitted as one M file using sections.
The sum of the following geometric series converges to 2 :
1+12+14+18+cdots=2
Geometric series is a series of numbers in which the ratio of the next term to the previous one is the same.
In the above case it is 12. Write a script according to the following instructions:
a) Using a while loop to check for convergence to 2. The convergence criterion is that difference
between the running total and the convergence value of 2 should be equal to or less than the error
0.000001. The script should output the number of terms needed and the final sum.
b) Repeat part (a) but use a for loop.
NOTE: Remember that in a while loop the conditional check is at the beginning of the loop and in a for
loop, if a conditional check is needed, it is OK to perform conditional check at the end of the loop, but
use the break command.
Consider the following matrices:
A=[2468],B=[57911]
Perform the following operations.
a) Create two new matrices U and V respectively using meshgrid function using A and B as input row
vectors.
b) Create a new matrix Z by dot multiplying U with V .
c) Create a matrix x which is similar to U but this time use the repmat function. Repeat this problem,
but create a matrix Y similar to V using the repmat function.
d) Create a matrix Q by dot dividing Z with X .Homework Assignment #2- Part 2
This assignment is worth 100 points and consists of two parts. This is Part 2, which covers user-controlled
data input and output. Both Part 1 and 2 are due Tuesday, October 8th on Canvas. Code must be
written in MATLAB, be well documented, and submitted as one M file using sections.
Recall the convergent geometric series from Problem #1 of Homework #2 Part #1. For this problem,
write a script that performs the following:
Prompt the user for input in the form of the number of terms to compute. Check for valid input,
and loop until the user enters a positive number greater than zero. If an invalid number is entered,
display a message reminding the user to enter a positive integer.
Use fprintf to output to the command window each term. See below for an example of what I
would like for the formatted output. Also, output to the command window the total as well as the
number of terms, as shown below. You may use either a while loop or for loop.
Example of the user entering 5(five terms):1.00000+0.50000+0.25000+0.12500+0.06250=1.93750," number of terms "=5
Specify five decimal places to the right of the decimal point for each term and the total, and no decimal
places for the number of terms.
Homework Assignment # 2 - Part 1 This assignment

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 Programming Questions!