Print out this page and fill in the blanks to answer the following
questions. Hand in this assignment at the beginning of
lab for the period. You should use the material
found in
Lecture 4 of the course notes and/or Matlab by Pratap Chapters 3.1,
3.2, 5.1.
This week's lab will be concerned with matrices. The following
exercises
should help prepare you for the
in-lab activities and MP1. Complete the following before coming to
lab.
a) >>A .* B
_____________________________________
b) >>A .^ B
_____________________________________
c) >>A * B
_____________________________________
d) >>B * A
_____________________________________
____________________________________________________________
b) complete the Matlab command to replace the
second column of the
matrix 'A' with the values in the vector [-1 0 1 0]
.
>> A( ________, ___________) = _______________________________
c) compute the following,
>> A = [ 1 2
3; 4 5 6; 7
8 9];
>> B = [ 6 ; 6];
>> C = [ A(1:2,2:3) , B]
C =
>> A= eye(2,3);
>> B = ones(2,3)
>> C = ones(1,6)
>> D = [ A , B ; C ]
D =
_____________________________________
>> v = [ 2 ; 2 ; 2 ; 2];
>> w = cumsum(v)
____________________________________
>> x = diff(w)
____________________________________
| K = |
|
>>a = _______________________________ % a should be a vector with numbers 1 through 5The matrix K you have just created is called a tri-diagonal matrix. Knowing how to use the 'diag' function will be useful in your next lab and machine problem assignment.
>>b = _______________________________ % b should be a vector with numbers 2 through 5
Proceed to define the matrices:
>>C = diag(a,0);
>>D = diag(b,________);
>>E = diag(b,________);
>>K = C ____ D ____ E;
>>A = ___________________________________________>>c = ___________________________________________
>>A\c = _________________________________________
What is the error message that Matlab displays?
____________________________________________________________________