14:440:127
Introduction to Computers for Engineers
Recitation 3 Problems for students to attempt Solutions
Please complete these problems on your own time if you do not finish in recitation. You don’t need to show us
the completed recitation problems, although we recommending saving a copy of your solutions for your own
benefit.
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
B =
C =
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
[
1
4
]
[
2
4
]
[
9
16
]
[
8
16 ]
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.
A*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')
%
or max(transpose(A))
min(A')
% or min(transpose(A))
c. Display the last row (using
end
)
A( end, : )
d.
What's the overall maximum value in the matrix?
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 blase
 Max

Click to edit the document details