Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
ELEC1703
MATLAB Assignment
Peter Peterson
Student ID number
Instructions:
- Insert your name and student number on cover page and document heading
- Most questions will require you to copy – paste what you did in MATLAB – you can do
this directly (copy-paste) or take a print screen (or use snipping tool in windows) and
paste a picture.
- Pasting snapshots via snipping tool in Windows is preferred. You may snapshot codes
as well.
- Comment your work. Your comments may carry 30 - 70% of the marks.
- Report format is guideline, feel free to change formatting style. Your main aim is to
create a neat summary of your work.
- When you are done, do not forget to update the table of contents on the first page. Right
click the table, click on Update Field, and choose Update entire table option.
Student ID number
1. Root finding algorithms – Bisection method
1.1 Bisection function (original)
Function code
(snapshot):
Function f(x) plot
(Make sure graph is properly labelled, and represented in neat manner)
Testing initial bisection function with f ( x )=x4−2 x−2 with 5 iterations
(snapshot of MATLAB Input/Output. Vary interval width and number of iterations
manually in order to derive their effect.):
Testing effects of interval width and number of iterations
(snapshot of MATLAB Input/Output. Vary interval width and number of iterations
manually in order to derive their effect.):
Comment
(Overall comment. Describe what you learned and what are the effects of the inputs of the
initial function. Check the original function code and explain what it does.)
Student ID number
1.2 Modified bisection function
Modified function code
(snapshot):
Code comments
(Describe how your code works and what you did, try commenting your lines within the code as
well.)
Main code
(snapshot):
Test the function for tolerance = 10−6
(snapshot of MATLAB output)
Plot of number of iterations vs tolerance with modified bisection function
(Make sure graph is properly labelled, and represented in neat manner)
Plot of number of iterations vs tolerance with false position function
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Overall comment. Describe what you learned and describe your observations on the graphs
by commenting the effects of tolerance variation and comparing two different functions)
Student ID number
2. Root finding algorithms – Newton method
2.1 Testing roots built-in function
Code
(snapshot – you can either write a script or use MATLAB command line directly):
Plot of f(x)
(Make sure graph us properly labelled, and represented in neat manner)
Comment
(Overall comment. Describe what you learned and describe how roots works)
Student ID number
2.2 Testing fzero built-in function
Code
(snapshot):
Test 1: Finding roots of f 1 ( x )=x4−2x−2
(snapshot)
Test 2: Finding roots of f 2 ( x )=x4−2x2+x
(snapshot)
Comment
(Overall comment. Describe what you learned and describe how fzero works)
Student ID number
2.3 Newton method – finding all zeroes automatically
mynewtontol function code
(snapshot)
Main code for filtration approach
(snapshot)
Plot of f ( x )=x4−2 x−2
(Make sure graph is properly labelled, and represented in neat manner)
Snapshot of roots array before and after filtration
Main code for incremental search algorithm
(snapshot)
Student ID number
Comment
(Comment on your observations)
Snapshot of roots with incremental search
Plot of f ( x )=x2−2x+1
(Make sure graph is properly labelled, and represented in neat manner)
Snapshot of roots array with filtration and incremental search approach
Comment
(Comment on your observations)
Incremental search hazards
Student ID number
Hazzard Example function
(Describe hazard) (Plot an example function that displays the hazard, make sure graph is properly labelled,
and represented in neat manner)
(Describe hazard) (Plot an example function that displays the hazard, make sure graph is properly labelled,
and represented in neat manner)
(Describe hazard) (Plot an example function that displays the hazard, make sure graph is properly labelled,
and represented in neat manner)
(Add/delete more rows to the table above if needed)
2.4 Newton method – effect of x
Main code
(snapshot)
Plot of number of iterations vs x0 for f ( x )=x4−2 x−2
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Comment on your observations)
Plot of f(x)/f’(x)
Student ID number
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Comment on your observations)
Plot of number of iterations vs x0 f ( x )=x2−2x+1
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Comment on your observations)
2.5 Newton method – effect of number of iterations
Main code
(snapshot)
Plot of number of iterations vs tolerance via Newton and bisection method
(Make sure graph is properly labelled, and represented in neat manner)
Comment
Student ID number
(Comment on your observations)
3. Function fitting - linear and nonlinear regression
3.1 Linear least-squares regression fitting
mylinregr.m function code
(snapshot)
Main code
(snapshot)
Plot of fitted data
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Overall comment. Describe what you learned and comment on your observations)
Student ID number
3.2 Polynomial fitting
Main code
(snapshot)
Plot of fitted data
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Overall comment. Describe what you learned and comment on your observations)
4. Interpolation
4.1 Lagrange interpolation
Student ID number
Lagrange interpolation function code
(snapshot)
Main code
(snapshot)
Population in 1945 – difference between Lagrange and linear fit
(snapshot)
Plot of fitted data by Lagrange interpolation and linear fit
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Comment on your observations)
Population in 2015 by Lagrange method
(snapshot)
Comment
Student ID number
(Overall comment. Describe what you learned and comment on your observations)
4.2 Inverse interpolation
a) 200 million
Code
(snapshot)
Plot of function for inverse interpolation
(Make sure graph is properly labelled, and represented in neat manner)
Year/s of 200 million population
(snapshot)
Comment
(Overall comment. Describe what you learned and comment on your observations)
b) Lagrange and quadratic regression comparison
Code
Student ID number
(snapshot)
Plot of function for inverse interpolation
(Make sure graph is properly labelled, and represented in neat manner)
Year/s when two fitting methods yield same result
(snapshot
Comment
(Overall comment. Describe what you learned and comment on your observations)
5. Numerical integration
Student ID number
5.1 Trapezoid integration
Trap2 function code
(snapshot)
Main code
(snapshot)
Plot of numerical error vs number of segments for the first function
(Make sure graph is properly labelled, and represented in neat manner)
Plot of numerical error vs number of segments for the second function
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Comment on your observations)
5.2 Romberg integration
Romberg function code
Student ID number
(snapshot)
Main code
(snapshot)
Plot number of iterations vs tolerance for the first function
(Make sure graph is properly labelled, and represented in neat manner)
Plot number of iterations vs tolerance for the second function
(Make sure graph is properly labelled, and represented in neat manner)
Comment
(Comment on your observations)