MCD 4140 Computing for Engineers Self Study Exercise 1
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
MCD 4140 Computing for Engineers
Self Study Exercise 1
Task 1
If you type the following commands into MATLAB, what will be the result?
1) A = 1 + 2 ^ 2 * 4
2) B = sqrt(sin(pi/2)*(6+3))
Task 2
Using the result from Task 1 for A and B, what is the value of B after typing this command into MATLAB?
B = B + A
What is the value in B if you type the above command again?
Task 3
Determine the size and contents of the following variables:
1) a = 7:2:11;
2) b = [a’ a’ a’];
3) c = b(1:2:3,1:2:3);
4) d = a + b(2,:);
5) e = [zeros(1,3) ones(3,1)’ 3:5’];
6) f = eye(3,3);
7) f(:,3) = a’;
8) f(3,:) = a([3 1 2]);
Task 4
1) Use two methods to create the vector x having 100 regularly spaced values starting at 5 and ending at 28.
2) Use two methods to create the vector x having a regular spacing of 0.2 starting at 2 and ending at 14.
3) Use two methods to create the vector x having 50 regularly spaced values starting at 一2 and ending at 5.
4) Create the vector x having 50 logarithmically spaced values starting at 10 and ending at 1000.
5) Create the vector x having 20 logarithmically spaced values starting at 10 and ending at 1000.
Task 5
Use MATLAB to create a vector x having six values between 0 and 10 (including the endpoints 0 and 10). Create an array A whose first row contains the values 3x and whose second row contains the values 5x 一 20.
Task 6
Type this matrix in MATLAB and use MATLAB to answer the following
questions: 「 3 | A = | −5 | 6 | L15 1) Create a 4 × 3 array B consisting columns of A . 2) Create a 3 × 4 array C consisting rows of A . 3) Create a 2 × 3 array D consisting last three columns of A . |
7 9 13 5 of all of all of all |
elements in the second through fourth elements in the second through fourth elements in the first two rows and the |
Task 7
What will these commands do when executed in order from (1) to (5)?
1) x = mod(0:4:16, 10);
2) y = linspace(0,10,5);
3) plot(x,y,’ko:’);
4) title(‘My x versus y Plot’);
5) sum(y) + mean(x);
Task 8
Write MATLAB code that does the following:
1) Creates an array called x with 100 values from 0 to 2π
2) Compute the values of y = sin2(x)/2 for each x value.
3) Plot your output (use a solid red line) and compare it against the graph of z = sin(x). (use a dotted blue line).
4) Add a title, axis labels and a legend to your graph.
Task 9
Given the matrices A Use MATLAB to: |
= |
2(6)4(4) |
16(2) B = |
1) Find the result of A times B using the array product.
2) Find the result of A divided by B using array right division.
3) Find B raised to the third power element-by-element.
Task 10
The scalar triple product computes the magnitude M of the moment of a force vector F about a specified line. It is M = (r × F) · n, where r is the position vector from the line to the point of application of the force and n is a unit vector in the direction of the line.
Use MATLAB to compute the magnitude M for the case where F = [10, −5, 4] N, r = [ − 3, 7, 2] m, and n = [6, 8, −7].
Task 11
Roots of polynomials appear in many engineering applications, such as electrical circuit design and structural vibrations. Find the real roots of the polynomial equation
4x5 + 3x4 − 95x3 + 5x2 − 10x + 80 = 0
in the range −10 ≤ x ≤ 10 by plotting the polynomial.
Task 12
A cable of length Lc supports a beam of length Lb , so that it is horizontal when the weight W is attached at the beam end. The principles of statics can be used to show that the tension force T in the cable is given by
L L W
T = b c
D L2 − D2
where D is the distance of the cable attachment point to the beam pivot. See figure below.
1) For the case where W = 400 N, Lb = 3 m, and Lc = 5 m, use element-by-element operations and the min function to compute the value of D that minimizes the tension T. (Do not use a loop.) Compute the minimum tension value.
2) Check the sensitivity of the solution by plotting T versus D. How much can D vary from its optimal value before the tension T increases 10 percent above its minimum value?
Task 13
The function y(t) = 1 – e-bt , where t is time and b > 0, describes many engineering processes, such as the height of liquid in a tank as it is being filled and the temperature of an object being heated. Investigate the effect of the parameter b on y(t). To do this, plot y versus t for several values of b on the same plot. How long will it take for y(t) to reach 98 percent of its steady-state value?
Task 14
Quenching is the process of immersing a hot metal object in a bath for a specified time to obtain certain properties such as hardness. A copper sphere 25 mm in diameter, initially at 300◦C, is immersed in a bath at 0◦C. The following table gives measurements of the sphere’s temperature versus time. Find a functional description of this data. Plot the function and
the data on the same plot.
Time (s) |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
Temperature ( °C) |
300 |
150 |
75 |
35 |
12 |
5 |
2 |
Task 15
The popular amusement ride known as the corkscrew has a helical shape. The parametric equations for a circular helix are
x = a cos t
y = a sin t
z = bt
where a is the radius of the helical path and b is a constant that determines the “tightness” of the path. In addition, if b > 0, the helix has the shape of a right-handed screw; if b < 0, the helix is left-handed. Obtain the three-dimensional plot of the helix for the following three cases and compare their appearance with one another. Use 0 ≤ t ≤ 10 π and a = 1.
1) b = 0.1
2) b = 0.2
3) b = −0.1
2022-11-30