CS113 Homework 2 Solved

35.00 $

Category: Tags: , ,

Description

5/5 - (1 vote)

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:

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 2:

Consider the array A, Compute the array B by computing the square roots of all the  elements  of A  whose  value  is  no  less  than  0  and  adding 50  to  each  element  that  is  negative

1

Problem 3.

Create two plots  1  and  2  in a single figure with the following expressions

=  +    =  −   where  − ≤  ≤ . Please set the x axis limit to be within [-3, 3] and y axis limit to  be within [-5,20]. Use legend to show each plot.

Problem 4.

Turn in the following:    1. A Word (.doc, .docx) document created using the MATLAB publish feature to publish  your script.    2. Your .m script file(s) (these are separate files from the document above). Make sure  you  use  plenty  of  comments.  Before  submitting,  rename  all  *.m  files to  have  a  .txt  extension. For example, rename MyHW6.m to MyHW6.txt before submitting.    Submit all files electronically on Blackboard. See syllabus for late assignment policy.

Late submissions will receive a 10% deduction!                      No submissions will be accepted after one day!

2

 

  • HW2-dmf6jf.zip