1. Create a vector with 15 elements: 1, 2, 3, . . . , 15. Then compute

(a) y =

t−1

t+1

(b) z =

sin(t

2

)

t

2

2. Calculate the following quantities:

(a) e

3

, ln(e

3

), log10(103

), and log10(105

).

(b) e

π

√

163

.

3. You know how to compute x

n element by element for a vector x and a scalar exponent n. How about

computing n

x

, and what does it mean? The result, again, is a vector with elements n

x1

, nx2

, nx3

, etc.

The sum of a geometric series 1 + r + r

2 + r

3 + . . . + r

n approaches the limit 1

1−r

for r < 1 as n → ∞.

Create a vector n of 11 elements from 0 to 10. Take r = 0.5 and create another vector x =

[r

0

r

1

r

2

. . . rn] with the x=r.^n command. Now take the sum of this vector with the command

s=sum(x) (s is the sum of the actual series). Calculate the limit 1

1−r

and compare the computed sum

s. repeat the procedure taking n from 0 to 50 and then from 0 to 100.

4. First read the MATLAB tutorial that I have posted on the Canvas site (and refer to the class notes).

Now create a vector and a matrix with the following commands:

v=0:0.2:12; and M=[sin(v); cos(v)];.

Find the sizes of v and M using the size command. Extract the first 10 elements of each row of the

matrix and display them as column vectors.

5. In class I showed you how to plot y = sin x, 0 ≤ x ≤ 2π, by taking 100 linearly spaced points in

the given interval. Now make the same plot again, but rather than displaying the graph as a curve,

show the unconnected data points. To display the data points with small circles, use plot(x,y,’o’).

[Hint: use the help plot command to learn about the different plotting options.] Now combine the

two plots with the command plot(x,y, x,y, ’o’) to show the line through the data points as well

as the distinct data points.

6. Plot y = e

−0.4x

sin(x), 0 ≤ x ≤ 4π, taking 10, 50, and 100 points in the interval. [Be careful about

computing y. You need array multiplication between exp(-0.4*x) and sin(x).]

The post MATLAB assignment first appeared on COMPLIANT PAPERS.

## Leave a Reply

Want to join the discussion?Feel free to contribute!