Matlab Assignment

profileZ.www

Create a Matlab script in an m-file which does all of the following. Name this file HW1.m. All commands

should be followed by a semi-colon; so that when the script is run, nothing gets displayed to the screen. To

receive full credit, you must use the exact variables names given below, and you must not have any terms

getting printed to the screen.

1. Your script should first clear all variables in the workspace using the “clear” command.

2. Define a variable “x” which is equal to 10 and a variable “y” which is equal to 50.

3. Create a length y vector (0,x,0,x,...,0,x) and call this vector “v”. (Try to create this using the variable

names “x” and “y” rather than their values of 10 and 50. This way if you later want to change the values,

it will be much easier.)

4. Create another length y vector called “w” containing equally spaced numbers between 0 and 10. (For

example, if y were equal to 6, then w would be equal to (0,2,4,6,8,10).)

5. Create a 9-by-9 matrix called “M” whose entries are all equal to 0 except that it has a single 12 in

the exact center of the matrix. (For example, if it were a 3-by-3 matrix, then the matrix would be [0,0,0;

0,12,0; 0,0,0].)

6. Make a vector “u” which is equal to the 5th column of M.

7. Make a length 9 vector “t” which is equal to (1,-3,9,-27,...).


    • 3 years ago
    • 20
    Answer(1)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      HW1.m