Starting from:

$30

CS113-Homework 1 Solved

Create a single MATLAB script with each problem below as a separate section (hint: %%).  

1.  Create a new script  

2.  Create a comment section at the top with your name, date, HW#, class, etc.  

3.  The first script commands should erase all the workspace data, command window output, and close all figures.  

4.  Create separate sections (%% ) for each problem

 

Problem 1:  

 Use MATLAB to evaluate the following expressions (a)      √𝟐

(b)               𝟑 +𝟒

𝟓+𝟔

(c)               Find the sum of 5 and 3 divided by their product

(d)               𝟐𝟑𝟐

(e)               Find the square of 2𝝅

(f)                𝟐𝝅𝟐

 

(g)       𝟏/√𝟐𝝅 
(h)                      Find the cube root of the product of 2.3 and 4.5

𝟏− 𝟐

(i)                         𝟑+𝟐𝟐

𝟏+𝟑−𝟐

(j)        𝟏𝟎𝟎𝟎(𝟏 + 𝟎. 𝟏𝟓/𝟏𝟐)𝟔𝟎 (k)   (𝟎. 𝟎𝟎𝟎𝟎𝟏𝟐𝟑 + 𝟓. 𝟔𝟕𝟖 × 𝟏𝟎−𝟑) × 𝟎. 𝟒𝟓𝟔𝟕 × 𝟏𝟎−𝟒 
 

 

Problem 2: 

  

Problem 3:  

Create another section to do the following. Add a comment at the end of each line detailing what each line does. Make sure command outputs are not suppressed so outputs are published in your final document (as well as to the command window).  a. Create the matrix  

                                                                                20    4    2    6

                                                                      𝐴 = 6    37    2    3

                                                                                  8    5    9    9

b.  assign the first row of A to a vector called x1  

c.   assign the last 2 rows of A to an array called y  

d.  assign the even-numbered columns of A to an array called B  

e.   assign the transpose of A (i.e. turns it into a 4-by-3 array) to C  

f.    compute the reciprocal of each element of A  

g.  change the number in column 2, row 3 of A to 100.
 

Problem 4:  

  

Problem 5: 

  

Problem 6 

a.       Calculate the monthly payment (P) for a loan using the following formula:  

  

where N is the number of years used to pay back the loan, r is the interest rate, and L is the loan amount. Set r to 15%, L to $50,000, and vary N from .5 to 20 years. If you enter your formula correctly P(20) = 658.39. Make sure to add comments explaining what the formula is doing.  

b.      Plot the monthly payment vs. the number of years (make sure you have enough data points to make a smooth curve).  

c.       Use the “text” command to print your name on the plot. Search MATLAB’s help files for information if needed.  

More products