8 Use indexing to set a single element of a vector

Create a new script and save it as q3.m.

In the newly created script, add the following:

% v is a vector of random integer values between 1 and 100
% v has between 5 and 10 elements
% everytime this script is run v may have a different
% number of elements and different element values 
v = randi(100, [1 randi([5 10], 1)]);

To the script, add some MATLAB statements that perform the following steps in order:

  1. using indexing, sets the first element of v to the value -999
  2. using indexing, sets the second element of v to the value pi
  3. using indexing, sets the last element of v 999
  4. using indexing, sets the middle element of v to 0. The middle element of v has the index equal to the number of elements in v divided by 2 rounded up to the nearest integer.