You are on page 1of 2

Review Problems: Week #1

Problem #1

1) Consider the vector x = [-4, -2, 0, 2, 4, 6, 8, 10, 12].

(a) Use the colon notation to generate a variable m that is identical to the variable x.

(b) Use the function linspace to generate a variable p that is identical to the variable x.

2) Consider the vector y = [6, 5.5, 5, 4.5, 4, 3.5].

(c) Use the colon notation to generate a variable s that is identical to the variable y.

(d) Use the function linspace to generate a variable t that is identical to the variable y.

Problem #2
Assume that the variables A and B, shown below, have already been generated in MATLAB.
 2 −1 3 5 
0 0 1 7 
  15 12 20 30
A = 9 2 6 3  𝐵 = [ ]
  50 70 90 80
 4 −7 −5 −2 
1 0 3 6 

1. Write one single MATLAB statement that generates the variable C, shown below, using the existing
variable A.
2 3
0 1
𝐶= 9 6
4 −5
[1 3 ]

2. Write one single MATLAB statement that generates the variable M, shown below using the variables A
and B.
15 12 20 30
50 70 90 80
𝑀=[ ]
2 −1 3 5
0 0 1 7

3. Consider the following MATLAB statements.

G = B; G(4,5) = 10;

What is G equal to after the above statements have been executed in MATLAB?
Problem #3
Assume the following variables have already been generated in MATLAB,

x = [4 8 5];
y = [3 1 2];

Specify the contents of the variables C1 through C4 generated by the following statements:

1. C1 = 1 + x.*y.^2;

2. C2 = y + 1./y;

3. C3 = x./y;

4. C4 = (x + y).*y;

Problem #4

Write a MATLAB code that:

1. Generates a linearly equally spaced vector t containing 20 elements, with a start value equal to 0 and an
end value equal to 8.

2. Calculates f(t), where

8 + cos 2 (3𝑡) 𝑒 −𝑡
𝑓(𝑡) = 1 +
1 + 𝑡3

You might also like