MATLAB Project. 1. Write two ... This project is worth 25% of the marks for
MATH10001. The project ... The project and report must be all your own work.
Anyone ...
MATH10001 Mathematical Workshop MATLAB Project 1. Write two script M-files to implement the repeated Trapezium rule and repeated Simpson's rule (described in the lecture notes) to approximate
1
with n strips. Your M-files should output the approximate value of the integral. Run your M-files for n = 4, 6 and 8. Calculate the integral by hand and compare with your answers above. Briefly explain the accuracy of your answers.
2. The ‘bubblesort’ algorithm takes a vector p with real number entries and sorts the entries into ascending order. e.g. For [3, 2, 4, 2, 1] bubblesort gives [1, 2, 2, 3, 4]. It does this by sweeping through the vector 1 times where length . At the first sweep ‘bubblesort’ compares p(1) and p(2) and swaps them if p(1) > p(2). It then compares the new p(2) and p(3) and swaps them if p(2) > p(3). It continues in this way until it reaches the end of the vector. The algorithm then repeats this process 1 times until the vector is sorted into ascending order. For the above example, ‘bubblesort’ gives the following vectors at the end of each sweep. [2, 3, 2, 1, 4], [2, 2, 1, 3, 4],
[2, 1, 2, 3, 4], [1, 2, 2, 3, 4].
Write a script M-file, to perform ‘bubblesort’ on any row vector p. The M-file should output the intermediate stages as in the example above. Test your M-file for p = [3, 2, 4, 2, 1] and p = [6, 5, 4, 3, 2, 1].
Project Report This project is worth 25% of the marks for MATH10001. The project report should be word-processed and include the answers to all questions, the M-files and their outputs. To gain all the marks, your M-files must contain comments to explain their structure and the report must be clearly presented. The project and report must be all your own work. Anyone suspected of sharing M-files or copying another student’s work will be dealt with by the Academic Malpractice Panel. You should submit your report to the Alan Turing Building Reception by 1pm on Friday 9th November. You should attach a School cover sheet to your report (available at reception).