or
2. Write down the equation that you are
going to solve, in the matrix form [matrix]*[column vector] = [column
vector]. (Hint: see the matrix equation in the MP 1 write-up
immediately above equation_1.)
The following answers should also be typed, in sequence, in your find_xy.m file.
4. Fill in the blanks to create the matrix A_main. Assume that the variable N has already been created.
A_main = diag( -(K(1:N)+K(2:N+1)) , 0 )
;
5. Fill in the blanks to create the matrix A_upper. Assume that the variable N has already been created.
A_upper = diag( K(2:N)
, 1 ) ;
6. Fill in the blanks to create the matrix A_lower. Assume that the variable N has already been created.
A_lower = diag( K(2:N)
, -1 ) ;
Now add the line of Matlab code,
A = A_main + A_upper + A_lower;
7. Fill in the blanks to modify the first and the last elements of the vector W :
W(1) = W(1) - K(1)*HL;
W(N) = W(N) - K(N+1)*HR ;
8. Fill in the blank
to solve the system of equations using the backslash (\) operator, and
store this result in a vector h.
h = A \ W ;
9. Fill in the blank to change h from a column vector into a row vector.
h = h' ;
10. Fill in the blank to prepend h with HL and append h with HR. (Hint: example, if h = [1 2 3 4 5] and HL = 0 , HR = 6 then we need to create [ 0 1 2 3 4 5 6])
h = [HL h HR] or [HL, h, HR] ;
% assign h to y , that's one of our output variablesy = h;
11. Fill in the blank to create a row vector x of distances from the left tower. You should have N+2 (7 for our example) elements in this vector. Assume the variable d (with N+1 elements) has already been created. (Hint: use 'cumsum' and prepend 0 )
x = [0 cumsum(d)] ;