a) >>A .* B
8 -2
0 6
_____________________________________
b) >>A .^ B
16 1
1 9
_____________________________________
c) >>A * B
8 2
4 8
_____________________________________
d) >>B * A
10
2
2 6
_____________________________________
9 8
7
3 2 1
_____________________________________
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( ___:_____,
____2_______) =
_____[-1
0 1 0]_____or___[-1
0 1 0] '____
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 =
2 3
6
5 6
6
_____________________________________
>> A= eye(2,3)
>> B = ones(2,3)
>> C = ones(1,6)
>> D = [ A , B ; C]
D =
1
0
0
1
1 1
0
1 0
1 1
1
1
1 1
1 1
1
>> v = [ 2 ; 2 ; 2 ; 2];
>> w = cumsum(v)
2
4
6
8
____________________________________
>> x = diff(w)
2
2
2
____________________________________
5. (8/10 point)Let P be
a 3 x 4 matrix. Which of the following are
valid
operations?
Circle the correct answers.
| P*P |
|
|
P'*P' |
|
P.*P' | P'.*P |
|
| K = |
|
6. Below is a sequence of Matlab commands for creating such a matrix. Fill in the blanks with the appropriate statements and operators to create the above matrix K:
>>a = ___[1 2 3 4 5]___ or [1:5] or linspace(1,5,5) % 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 =
___[2 3 4 5]___or [2:5] or linspace(2,5,4) % b should be a vector with numbers 2 through 5Proceed to define the matrices:
>>C = diag(a,0);
>>D = diag(b,___1___);
>>E = diag(b,___-1___); OR -1 for D and 1 for E
>>K = C __+___ D ___+___ E;
>>A = ____[2 -1 2; 1 3 1; 3 4 -4]_________8. Not all systems of linear equations have a unique solution. Try solving the system below using the backslash operator:>>c = ____[6; 10; -1]___
>>A\c = ___ [ 1.0000 ; 2.0000 ; 3.0000]_ but no deduction for the same values dispalyed in row format rather than column format__
What is the error message that Matlab displays?
Warning: Matrix is singular to working
precision. (This is sufficient for a "correct answer".)
NaN
Inf
Inf
-----------------------------------------------------------------------------------------------------------