Você está na página 1de 10

THE UNIVERSITY OF THE WEST INDIES

ST. AUGUSTINE, TRINIDAD & TOBAGO, WEST INDIES


FACULTY OF ENGINEERING
Department of Electrical & Computer Engineering
B. Sc. in Electrical & Computer Engineering

ECNG 1006
MATLAB EXERCISE
EXERCISE 1
Array and Matrix Operations
Operations

Contents
1.

General Information ................................................................................................................ 3

2.

Lab Learning Outcomes .......................................................................................................... 4

3.

In-Lab ...................................................................................................................................... 4

Lab # 5: MATLAB EXERCISE 1

ECNG 1006
Lab and Project Design I
http://myelearning.sta.uwi.edu/
Semester II; 2008 / 2009

1. GENERAL INFORMATION
Lab #:
Name of the Lab:

Lab Weighting:

5%

Delivery mode:

 Lab:

Venue for the Lab:

SHARED LAB

Lab Dependencies

The theoretical background to this lab is provided in ECNG 1000,


ECNG 1009, MATH 1180

Recommended
prior knowledge
and skills:

Course Staff

MATLAB EXERCISE 1: Array and Matrix Operations


Estimated total
study hours:

Yes

To undertake this lab, students should be able to:


Perform basic matrix operations
Solve polynomial, quadratic equations and simple electrical
based problems

Position/Role

E-mail

Dr. Ronald De Four

Course Lecturer

Ronald.DeFour@sta.uwi.edu

Juliet Romeo-Joseph

Engineering Practice Coordinator

Juliet.Romeo@sta.uwi.edu

Adelle Joseph

Course Coordinator

Adelle.Joseph@sta.uwi.edu

Azim Abdool

Lab Demonstrator

Azim.Abdool@sta.uwi.edu

Lab # 5: MATLAB EXERCISE 1

2. LAB LEARNING OUTCOMES


Upon successful completion of the lab assignment, students will be able to:
1. Apply mathematical simulation tools for the numerical solution of
differential equations. (Programming in Matlab and use of Eulers method
for the numerical solution of differential solutions)

Cognitive
Level
Application

3. IN-LAB
Allotted Completion 3 hours
Time:
1 PC with MATLAB version 6.5 or higher
Required lab
Equipment:

3.1. Array and Matrix Operations

Use the MATLAB workspace to provide solutions to the following:


3.1.1

For the matrix:

3 7 4 12
5 9 10 2

A=
6 13 8 11

15 5 4 1

a. Create a vector v consisting of the elements of the second column of A.


b. Create a vector w consisting of the elements of the second row of A.
c. Create a 4 by 3 array B consisting of all the elements in the second through fourth
columns of A.
d. Create a 3 by 4 array C consisting of all the elements in the second through fourth
rows of A.
e. Create a 2 by 3 array D consisting of all the elements in the first two rows and last
three columns of A.

Lab # 5: MATLAB EXERCISE 1

3.1.2

For the matrices:


7 16
6 5
A=
B
=

12 2
4 9

3 9
C=
8
6

a. Find A + B + C
b. Find A - B + C
c. Verify the associative law
(A + B) + C = A + (B + C)

3.1.3 Find the dot product of the following vectors:


a. u.w where:
u = 6i 8 j + 3k
w = 5i + 3 j 4k

b. AB where:

7 4
A = 3 2
5 9

1 8
B=

7 6

c. For the following matrices show that AB is not equal to BA:

6 2
A=

10 3

8
9
B=

12 14

d. For A and B in part c find A.B.


e. Find the determinant of A and the inverse of A.

Lab # 5: MATLAB EXERCISE 1

3.2 Linear Algebraic Equations

The following set of equations:

ax1 + bx2 = c
dx1 + ex2 = f
can be represented in the following compact form of Ax = y where

x
x = 1
x2

a b
A=

d e

and

Hence to solve this x = A-1y.

3.2.1 Use the above method to solve the following:

a.

2x + 9 y = 5
3x 4 y = 7

b.

3x 4 y = 5
6 x 10 y = 2

c.

3 x + 2 y 9 z = 65
9 x 5 y + 2 z = 16
6 x + 7 y + 3z = 5

d.

[x1

62
x2 ] = [3 19]
35

c
y=
f

Lab # 5: MATLAB EXERCISE 1

3.2.2 The above problems may be solved using the left division method \. Use MATLAB help
to find out more on this and repeat a, b and c using the left division method.

3.3. Polynomials
Polynomials are usually described using the following notation:

f ( x) = a1 x n + a 2 x n1 + a3 x n 2 + K + a n x + a n+1
where the polynomial is a function of x and n is the highest order or power of the polynomial.
Polynomials can be described as row vectors in MATLAB starting with the highest power of x.
For example:
f ( x) = ax 3 + bx 2 + cx + d
may be represented in MATLAB by the coefficient array:
f = [ a , b, c , d ]

3.3.1 Use MATLAB help to find out about the conv and deconv commands to perform
polynomial products and divisions.

a. For:
f ( x) = 9 x 3 5 x 2 + 3x + 7
Find f(x)g(x) and

and

f ( x)
g ( x)

b. Find
(20 x 3 7 x 2 + 5 x + 10)(4 x 2 + 12 x 3)

c. Find the remainder and quotient of:


12 x 3 + 5 x 2 2 x + 3
3x 2 7 x + 4

g ( x) = 6 x 2 x + 2

Lab # 5: MATLAB EXERCISE 1

3.3.2 Use MATLAB help to find out about the roots command to find the roots of a polynomial
when f(x) = 0.

a. Find the roots of x 3 7 x 2 + 40 x 34 = 0


b. Find the roots of 5 x 3 + 167 x 2 + 174 x + 2135 = 0
c. Use the ployval command to confirm the answers ( a and b) above.

3.4 Simple Plotting in MATLAB

3.4.1 For values of x between -6 and 6 plot the polynomial:


3 x 5 + 2 x 4 100 x 3 + 2 x 2 7 x + 90
Using increments of:
a. 1
b. .1
c. .01
d. .001
(Hint: Use the polyval command)
Label the x and y axis using the xlabel and ylabel commands.

Qu. What can you observe by decreasing the x increments?

3.4.2 For y = tan(x) and z = sec(x), where x are values between 0 and 1 in increments of 0.01,
plot y and z on the same figure. Let the plot of y be a red line with x points and let the plot of z
be a dashed green line with o points.

3.4.3 Use MATLAB help to find out about the subplot command.
Using the subplot command, plot:
a. y = e 1.2 x sin(10 x + 5) for 0 < x < 5
b. y = x 3 100 for -6 < x < 6

Lab # 5: MATLAB EXERCISE 1

3.5 Load Line Analysis of Electrical Circuits


The figure below shows an electrical system with a power supply and a load. The power supply
produces a fixed voltage v1 and supplies a current i1. The voltage drop across the load is v2. The
current-voltage relationship for a specific load is given by:
i1 = 0.16(e 1.2v 2 1)
Given the resistance R1 = 30 and v1 = 15V
By applying Kirchoffs Voltage Law and plotting i-v Load Line and Device Curve relationships
on the same plot, find the current drawn from the power supply and the voltage drop across the
load.

3.6 Frequency Response of a Low-pass Filter

For a sinusoidal input at vi, the Input / Output ratio (Ao/Ai) of the low pass filter shown in the
figure below is given by the expression:

Ao
1
=
Ai RCs + 1
where s = i. For RC = 0.1 sec, obtain the loglog plot of |Ao/Ai| versus .
(Hint: s = [1:100]*i. Use the imag and loglog MATLAB commands).

Lab # 5: MATLAB EXERCISE 1

Due Date:
Submission
Procedure:
Deliverables:

February 20, 2009 @ 4PM


Submit to Mr. Krystan Chance in the Shared Lab

Signed Plagiarism Declaration Form


Typewritten responses to the in-lab questions ONLY, bound in a
folder.

End of Lab # 5: Matlab Exercise 1


Array and Matrix Operations

Você também pode gostar