Professional Documents
Culture Documents
Faculty of Engineering
Semester 1 - 2014
Page 1 of 3
Task 2 2 marks
All points with coordinates x = rcos() and y = rsin(), lies on a circle with radius r.
Write a MATLAB code that creates a vector for with 9 values from 0 to 2 and
uses r = 2 to plot the coordinates of x vs y (using a red line) to check if a circle
with radius 2 is actually obtained (if not, what would you change in the code to fix
the problem).
Note: Ensure your plot is labelled
Task 3 2 marks
Using MATLAB and these two matrices
A=
100
10
B = ln(A)
( 1)n
n =0
(2n + 1)!
sin ( x ) =
x 2 n +1
n
(
1) 2 n
cos( x ) =
x
n =0 (2n )!
Page 2 of 3
Prior to the advent of modern computing, this series solution was used to provide
accurate estimates of sin(x) and cos(x). Now, computer programs use the same
technique to estimate sine.
a) Write an M-file which will calculate sin(/5) using from one to six terms
(for n up to 0, n up to 1 n up to 5) in the series solution. For each of the
six cases, compare the answer from the series solution to the answer
given from the MATLAB built-in function sin(x) as a percentage error.
b) Write an M-file program which calculates tan(x).
sin( x)
Note: Use the trigonometric identity tan( x) =
cos( x)
The program should use the first six terms (n up to 5). Calculate the Taylor
tan approximation values of x going from to in 0.1 increments. Plot
the absolute error between your Taylor tan(x) approximation and
MATLABs built-in tan function.
Note: Absolute _ error = approx true
Task 5 3 marks
A simply supported beam that is subjected to a constant distributed load w over
two-thirds of its length is shown below.
wL 3
40 2
4 3
2
2 x 6 Lx + L x L
54 EI
9
9
for
2
L x L
3
Where E is the elastic modulus, I is the moment of inertia and L is the length of
the beam.
For the case where L = 20m, E = 200 x 109 Pa, I = 348 x 10-6 m4, and w = 5 x 103
N/m, write a MATLAB code that plots the deflection of a beam (y) as a function of
the beam length (x) and use matrix addressing to find the maximum deflection of
the beam and where along the beam does it occur.
Laboratory No.2 (Week 3)
Page 3 of 3