Introduction to Computers for Engineers
Recitation 3  Problems Solutions
1)
Create a row vector containing the even numbers 2 through 18, a column vector
containing 1,5,9,…,25,29, and a 3*3 matrix
A.
Then, transpose
A
and save that as
B
.
Finally, calculate the element by element (dot) multiplication of
A
and
B
.
b = 2:2:18;
c = transpose(1:4:29);
A = [5 2 6 ; 7 3 2; 7 2 9];
B = A';
A.*B
2)
Given the arrays x = [1 4 8], y = [2 1 5] and A = [3 1 6 ; 5 2 7],
determine which of
the following statements will correctly execute and provide the result.
If the command
will not correctly execute, state why it will not.
a. x + y
[
3
5
13
]
b. x + A
Nope adding matrices requires that they be the same size
c. x' + y
Nope adding matrices requires that they be the same size (exactly).
Here, one's
a column vector and one's a
row vector, so the sizes are technically different.
It's kind of annoying, right?
d. A  [x' y']
Nope adding matrices requires that they be the same size (exactly).
Here, one's
a column vector and one's a
row vector, so the sizes are technically different.
It's kind of annoying, right?
e. [x ; y']
Nope, the dimensions don't work.
You would need
y
to have the same number of
columns as
x
f. [x ; y]
[
1
4
8
]
[
2
1
5
]
g. A – 3
[
0
2
3
]
[
2
1
4
]
3)
. If A = [1 2; 3 4]; Predict the values of B = A.^2 and C = 2.^A on paper and verify using
matlab
4)
Create two 4 x 4 matrices A and B and calculate the following values. (You should
store each of them in a variable with some name of your choosing.) In theory, which of
the following matrices do you expect to be equal? Which ones actually are equal?
Check your answers with Matlab.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentA*B
B*A
A + B
B + A
A+B and B+A are equal;
A*B and B*A are usually not equal.
5)
Given the matrix,
A = [ 3 7 4 16;
5 9 10 2;
6 13 8 11;
15
5
4 1].
a. Find the maximum and minimum values in each column;
max(A)
min(A)
b. Find the maximum and minimum values in each row.
max(A')
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 Finch
 Max

Click to edit the document details