Lab 3
Lab 3
Lab 3
Exercises
Exercise 1
Test your understanding problems: T4.5-3, T4.6-2, T4.7-1 (Intro Matlab 7 ed3); T4.5-
1, T4.5-3, T4.6-1 (Intro Matlab 7 ed2); or T4.4-1, T4.4-3, T4.5-1 (Intro Matlab 6).
Easy Plotting
MATLAB has a number of functions for use when data points do not have to be
specified exactly. The function fplot plots functions defined by a M-file name or
function handle. Thus
fplot('sin', [0 2*pi])
or, equivalently,
fplot(@sin, [0 2*pi])
plot the sine function over the range shown. MATLAB does the job of working out
numbers of data points, etc. The function title, axis, etc can be used as with plot.
The function ezplot plots functions defined by string expressions. Using
ezplot('sin(x)/x', [-10 10])
it plots sin( x) / x over the range specified. It can also be used to plot an implicit
function. For example,
ezplot('x^2+(y/3)^2-1', [-2 2 -4 4])
Where M is the mark, C the credit point value and Y the year (values of 1, 2, 3 or 4).
Honours are awarded as follows: H1 for GWAM 75, H2(1) for 75 >GWAM 70,
H2(2) for 70 >GWAM 65. Write a function which will accept a 3-column matrix
containing a mark, credit point value and year in each row and will return a value for
the GWAM (it could consist of just one line).
Laboratory 3 1
ELEC2103 Simulation & Numerical Solutions in Engineering - 2015
a 0 1, b0 1 k 2
a n a n 1 bn 1 / 2, bn a n 1bn 1 , n 1, 2,
Both sequences have the same limit g and K (k 2 ) . Also, a n bn for all n.
2g
2
Write a MATLAB function that computes the elliptic integral K ( k ) . Use a while
loop to generate the sequences and continue looping until a n bn eps , where eps is
the relative floating point accuracy value returned by the MATLAB function eps.
Write your code so that the function takes either a single number or an array of
numbers as k2-values. Your code should use only one loop, the while loop. Return the
answer in the same format (row or column vector) as the input.
What is the value of the elliptic integral for k2 = 0.4, 0.5, 0.6?
Answer: 1.7775, 1.8541, 1.9496
Laboratory 3 2
ELEC2103 Simulation & Numerical Solutions in Engineering - 2015
Exercise 6
Chapter 4, Problem 26 in IM7ed3, 23 in IM7ed2; 16 in IM6
Exercise 7
Chapter 4, Problem 37 in IM7ed3; 31 in IM7ed2; 24 in IM6
Exercise 8
Chapter 4, Problem 38 in IM7ed3; 32 in IM7ed2; 25 in IM6
Exercise 9
Chapter 4, Problem 28 in IM7ed3; 25 in IM7ed2; 18 in IM6
Laboratory 3 3