Anda di halaman 1dari 14

ARRAY & MATRIX OPERATIONS USING MATLAB

Lab Exercise No. _____

MATLAB array & matrices

I. OBJECTIVES
To perform basic operations and use arrays in MATLAB such as
1. Perform array operations including addition, subtraction, multiplication, division
and exponentiation.

1gm

2. Perform matrix operations including addition, subtraction, multiplication, division


and exponentiation.
II. MATERIALS & EQUIPMENT
(1) PC
(1) MATLAB v6 or higher

MATLAB array & matrices

III. WORKED EXAMPLES


1. TRANSPORTATION ROUTE ANALYSIS. The following table gives data for the distance
traveled along five truck routes and the corresponding time required to traverse
each route.

2gm

1
560

2
440

Distance
(miles)
Time (hrs)
10.3
8.2
Table 1. Transportation Route Data

MATLAB array & matrices

Solution:

3gm

distance = [560 440 490 530 370];


time =
[10.3 8.2 9.1 10.1 7.5];
%a
speed = distance./time

3
490

4
530

5
370

9.1

10.1

7.5

1
2
4
R (ohms)
10
2 x 104
V (volts)
120
80
Table 2. Resistance & Voltage Data
Solution:

MATLAB array & matrices

R = [1e4 2e4
3.5e4 1e5
V = [120 80
110
200
current = V./R
power_dissipation = V.^2./R

4gm

2e5];
350];

3
3.5 x 104
110

4
105
200

5
2 x 105
350

Output:
current =
0.0120

0.0040

0.0031

0.0020

0.0018

power_dissipation =
1.4400 0.3200 0.3457

0.4000

0.6125

MATLAB array & matrices

4. SPECIAL PRODUCTS. Use MATLAB to compute the dot product of the following
vectors:
U = 6i 8j + 3k

5gm

Process

Hours Required to Produce One Unit


Product 1
Product 2
Product 3

Hourly Cost
($)
Lathe
10
6
Grinding
12
2
Milling
14
3
Welding
9
4
Table 3. Manufacturing Cost Analysis

MATLAB array & matrices

Solution:

6gm

5
3
2
0

4
1
5
3

(a) Calculation of Process Cost:


hourly_cost_Process = [10 12 14 9];
Product1_hours = [6 2 3 4];
Process_cost = hourly_cost_Process .* Product1_hours

Output:
Process_cost =
60 24 42

36

MATLAB array & matrices

(b) Calculation of Unit Cost:

7gm

Product2_hours = [5 3 2 0];

MATLAB array & matrices

Path Segment
1
2
3
4
Force (N)
400
550
700
500
Distance (m)
2
0.5
0.75
1.5
Table 4. Force Data
Use MATLAB to find
(a)
The work done on each segment of the path, and
(b)
The total work done over the entire path.

8gm

5
600
3

Material
1
2
3
4
5

Price ($/ton)
300
550
400
250
500

Quantity Purchased (tons)


May
June
5
4
3
2
6
5
3
5
2
4

July
6
4
3
4
3

MATLAB array & matrices

Use MATLAB to answer the following questions:


a. Create a 3 x 5 matrix containing the amounts spent on each item for
each month.

9gm

MATLAB array & matrices

b. What is the total spent in May? In June? In July?


c. What is the total spent on each material in the three-month period?
d. What is the total spent on all materials in the three-month period?

10gm

11gm
MATLAB array & matrices

MATLAB array & matrices

4.

12gm

ELECTRICAL RESISTIVE NETWORK ANALYSIS (Mesh)


The electrical circuit shown below consists of resistors and voltage sources.
Determine the current in each resistor using the mesh current method which is
based on Kirchhoffs voltage law.
V1 = 20 V, V2 = 12 V, V3 = 40 V
R1 = 18 , R2 = 10 , R3 = 16
R4 = 6 , R5 = 15 , R6 = 8
R7 = 12 , R8 = 14

R 1
18
V1
20Vdc
R 2

R 3

10

16
V2
12Vdc

R 4
6
R 5

MATLAB array & matrices

R 8

13gm

14
8

V3

R 6
12

40Vdc
R 7

12

MATLAB array & matrices

Most of the materials came from Palm IIIs book MATLAB.

14gm

Anda mungkin juga menyukai