# Computer Skills and Sustainability: MATLAB Assignment

## Problem 1 Matrix Operation (20 Marks)

### P1-1 (5 Marks, 1 Mark for each small question)

Type this matrix in MATLAB and use MATLAB to carry out the following instructions.

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

### P 1-2 (5 Marks, 1 Mark for each small question)

Consider the following arrays:

Write MATLAB expressions to do the following. a) Select just the third row of B. b) Evaluate the sum of the second row of B. c) Multiply the second column of B and the first column of A element by element. d) Evaluate the maximum value in the vector resulting from element-by-element multiplication of the second column of B with the first column of A. e) Use element-by-element division to divide the first row of A by the first three elements of the third column of B. Evaluate the sum of the elements of the resulting vector.

### P 1-3 (5 Marks)

A mass m is suspended by three cables attached at three points B, C, and D, as shown in Figure

- Let T1, T2, and T3 be the tensions in the three cables AB, AC, and AD, respectively. If the mass m is stationary, the sum of the tension components in the x, in the y, and in the z directions must each be zero. This gives the following three equations:

Figure 1. A mass suspended by three cables. Determine T1, T2, and T3 in terms of an unspecified value of the weight mg. (Hints: you can assume mg = 1, and find the values of T1, T2 and T3, respectively, and the final expressions should be these values multiplied by mg.)

### P 1-4 (5 Marks)

Engineers must be able to predict the rate of heat loss through a building wall to determine the heating system requirements. They do this by using the concept of thermal resistance R, which relates the heat flow rate q through a material to the temperature difference ∆? across the material: ? = ∆?/?. This relation is like the voltage-current relation for an electric resistor: ? = ?/?. So, the heat flow rate plays the role of electric current, and the temperature difference plays the role of the voltage difference. The SI unit for q is the watt (W), which is 1 joule/second (J/s). The wall shown in Figure 2 consists of four layers: an inner layer of plaster/lathe 10 mm thick, a layer of fiber glass insulation 125 mm thick, a layer of wood 60 mm thick, and an outer layer of brick 50 mm thick. If we assume that the inner and outer temperatures Ti and To have remained constant for some time, then the heat energy stored in the layers is constant, and thus the heat flow rate through each layer is the same. Applying conservation of energy gives the following equations.

The thermal resistance of a solid material is given by ? = ?/? , where D is the material thickness and k is the material’s thermal conductivity. For the given materials, the resistances for a wall area of 1 m2 are ?1 = 0.036, ?2 = 4.01, ?3 = 0.408, and ?4 = 0.038 K/W. Suppose that ?? = 20 ℃ and ?? = −10 ℃. Find the other three temperatures and the heat loss rate q, in watts. Also, compute the heat loss rate if the wall’s area is 10 m2.

Figure 2. The schematic for P1-4.

## Problem 2 (20 Marks)

### P2-1 (10 Marks, 7 Marks for programming and 3 Marks for displaying results)

The equation of motion for a pendulum whose base is accelerating horizontally with an acceleration a(t) is ??̈ + ? sin ? = ?(?) cos ? Suppose that ? = 9.81 ?/? 2 , ? = 1 ?, and ?̇ (0) = 0. Plot ?(?) for 0 ≤ ? ≤ 10 ? for the following three cases: a) The acceleration is constant: ? = 5 ?/? 2 , and ?(0) = 0.5 ???. b) The acceleration is constant: ? = 5 ?/? 2 , and ?(0) = 3 ???. c) The acceleration is linear with time: ? = 0.5? ?/? 2 , and ?(0) = 3 ???.

### P2-2 (10 Marks, 7 Marks for programming and 3 Marks for displaying results)

The following equation describes the motion of a certain mass connected to a spring, with no friction 3?̈ + 75? = ?(?) where ?(?) is an applied force. Suppose the applied force is sinusoidal with a frequency of ? ???/? and an amplitude of 10 N: ?(?) = 10 sin(??). Suppose that the initial conditions are ?(0) = ?̇ (0) = 0. Plot ?(?) for 0 ≤ ? ≤ 20 ?. Do this for the following three cases. Compare the results of each case: a) ? = 1 ???/? b) ? = 5 ???/? c) ? = 10 ???/?

### Problem 3 (20 Marks, 5 Marks for a) and 15 Marks for b))

The equations for an armature-controlled dc motor (Figure 3) are the following. The Motor’s current is i and its rotational velocity is ?.

where L, R, and J are the motor’s inductance, resistance, and inertia; KT and Ke are the torque constant and back emf constant; c is a viscous damping constant; and ?(?) is the applied voltage.

Use the values ? = 0.8 Ω, ? = 0.003 ?, ?? = 0.05 ? ∙ ?/?, ?? = 0.05 ? ∙ ?/???, ? = 0 and ? = 8 × 10−5 ?? ∙ ?2 . a) Suppose the applied voltage is 20 V. Plot the motor’s speed and current versus time. Choose the simulation time period large enough to show the motor’s speed becoming constant. b) Suppose the applied voltage is trapezoidal as given below.

Plot the motor’s speed versus time for 0 ≤ ? ≤ 0.3 ?. Also plot the applied voltage versus time. How well does the motor speed follow a trapezoidal profile? For both a) and b), the initial conditions are ?(0) = 0 and ?(0) = 0 . You can use either MATLAB programming (read Tutorial 1 for solving ODEs) or Simulink (read Lecture 3).

Figure 3. The armature-controlled dc motor of Problem 3.

## Problem 4 (25 Marks, with 1) 10 Marks, 2) 15 Marks)

Consider a circuit system as shown in Figure 4.

Figure 4. A circuit with multiple resistors and inductors for Problem 4. Question: 1) Derive the equations for ?1 (?) and ?? (?) for all ?. 2) Obtain the plots of ?1 (?) and ?? (?) for all ?.

## Problem 5 (15 Marks, with 1) 5 Marks, 2) 5 Marks, 3) 5 Marks)

A dynamic structure diagram of a control system is shown in Figure 5: Figure 5. The dynamic control system for Problem 5. Where .8? + 1? The input is taken as the step input and ? is the deadband value of the magnetic loop property. ?(?) = Question: 1) Use MATLAB/Simulink to establish the system. 2) Analyze the influence of ?1 value on the output performance of the system. 3) Analyze the influence of input amplitude on the output performance of the system.