Vous êtes sur la page 1sur 2

Name: ____________________________________________

CECS 463 System-on-Chip


Homework Assignment #2: MATLAB

Due: 2/7/2012

I. Enter these commands interactively in sequence in MATLAB and record results. Be sure to understand what
operations are being done in each case.
Arithmetic Exercises
1. r=12.5; V=(4/3)*pi*r^3

V= ___________

2. a=2+3j ; b=5-2j; c=a*b

c = ___________ Complex multiply

3. y=[1:1:10]

y(7)= _________

4. D = [1 2 6; 0.5 -4 2; 1 1 -1]
x = det(D)

Volume of sphere

1x10 Row Vector


3x3 Matrix
Determinant

x= _________

5. D = [1 2 6; 0.5 -4 2; 1 1 -1];
Dinv = inv(D); D*Dinv
D(i,i)= ________

( 1 i 3 )

Identity Matrix

6. t=[0:0.01:2*pi]; clf; plot(cos(t),sin(t));hold on; grid;


x=(-3+5j); x=x/abs(x);plot([0 real(x)],[0 imag(x)],-rx);
p=atan(imag(x)/real(x))*180/pi
p=__________ (is this right?)
7. y=[100:-5:0]

y(12) = _____

8. x=[1 2 3]; y=[-2 -3 4]; z = x .* y


9. x=[1 2 3];

z=x.^2

z =[ ____

z = [ ___

10.

x=[1 2 3]; z = x*x

11.

x=[0,1,3,7,12,23,29]; y=fliplr(x);

12.

x=sum([1:3:21].^2)

13.

x=[1 2 3]; z=x*x

14.

A=[1

1; 2 -1]; B=[-1

Transpose: row to column vector

____

z= [______]

____

___

____ ] Product of elements

Elements squared

Scalar result (1x3 3x1=1x1)

y= [ __

__

__

__

__

__

__ ]

x= [ _______ ]
z=[ _____

_____

_____ ] 3x3 Matrix result (3x1 1x3=3x3)

[ _____

_____

_____ ]

[ _____

_____

_____ ]

2; 2 1];

C=A*B
C= [_____
[_____

______ ] (2x2 2x2=2x2)


______]

Plotting Exercises
15. Plot the sinusoid x=2*cos(2*pi*t+ 3*pi/8) using t=[0:0.05:4]. From the plot,
approximate the value of x(0.5) and x(2.75).
ANS: x(0.5) =__________

x(2.75)= _________

16. Plot the function y(t)=5*exp(-0.05*t.*t).*cos(5*t) using t=4*pi*[0:0.01:1] and


approximate when the function decays to one-half its value at t=0.
ANS: __________
17. Find the zeros of the function f(t) = 4t3 15t2 + 2t + 10 by plotting the function
and approximating where it crosses the t-axis.
ANS: Zeros at values of t = ____________________
18. Plot a circle of radius 5 centered at point (-2,3).
DEMO: ______
19. Plot a quadrilateral with vertices at points (-1,-3), (1, -5), (2,4) and (-2,1).
DEMO: ______
20. (a) Plot two sinusoids, x(t)=2cos(30t+30o) and y(t)=3cos(30t-50o), and their sum
z(t)=x(t)+y(t). Put the three plots on the same graph. Annotate the plot to indicate
which plot is which. What is the approximate amplitude and phase in degrees of z(t) read
from the plot?
ANS: z(t) Amplitude=__________

z(t) Phase = _________

(b) Express x(t) and y(t) as complex number phasors X and Y respectively. Form the sum
Z=X+Y and determine the magnitude of resulting phasor Z and the phase angle of Z.
ANS:

|Z| = ____________

Zangle(degrees) = arctan(ImZ/ReZ)*180/ = _________

(c) Plot two sinusoids, x(t)=2cos(30t+30o) and y(t)=3cos(25t-50o), and their sum
z(t)=x(t)+y(t). What is the period (distance between maxima) of z(t)and how is it related
to the frequencies of x(t) and y(t)?
ANS: Period of z(t)= ___________ and frequency = 1/Period = _______________
ANS: Relationship: _________________________________________________________

Vous aimerez peut-être aussi