程序代写代做代考 matlab MECH 5315M – Engineering Computational Methods

MECH 5315M – Engineering Computational Methods
Exercise 1
Please return by Friday 21 October 2016. The report consists of three files of Matlab code and a written document and you will need to submit both to get full marks.
Code you need to write in Matlab.
1. Implement in Matlab the explicit fourth order Runge-Kutta method
k1 =f(tn,φn)
k2 =f(tn +0.5∆t,φn +0.5∆tk1) k3 =f(tn +0.5∆t,φn +0.5∆tk2) k4 =f(tn +∆t,φn +∆tk3)
φn+1 = φn + ∆t (k1 + 2k2 + 2k3 + k4) 6
for the forced linear oscillator
or, in system form,
􏰔 x ̇ ( t ) 􏰕 v ̇(t)
=:φ
Your method should be implemented as a function called rk4.m that receives arguments φ0, b,
Ω0, ∆t, and the number of steps to compute and return a vector containing all computed φn.
2. Devise and implement a test that checks whether your implementation is correct. The test must be a script called test rk4.m, running without any additional input and display only a single line of output, indicating whether the test was successful or not.
3. Write a script called make figure.m that generates a plot showing the forcing frequency Ω on the x-axis against the modulus of the solution for x(0) = 1.0, x ̇(0) = 0.0 at a final of T = 100.0 on the y-axis. The script must run without any additional input.
Please email these three Matlab files to d.ruprecht@leeds.ac.uk. Please use MECH5315M Exercise 1 as subject and state your name and student number in the body of the email.
What to write in the report. Your report should be between 1 and 2 pages long using at least font 11 and 2cm margins. Please print out your code and attach it to the report (of course the printed code does not count toward the 2 page limit). Try to be concise! Please structure your report along the following four paragraphs:
1. Introduction – write down the method and describe briefly the problem you are solving.
2. Testing – describe the test you used to make sure your implementation is correct.
3. Results – include the generated figure and describe what it shows but without interpreting the results.
4. Interpretation – give an explanation of the results you described in the previous paragraph.
x ̈(t) + bx ̇(t) + x(t) = cos(Ω0t)
􏰔 x ( t ) 􏰕 􏰔 v ( t ) 􏰕
= f(t, v(t) ) = cos(Ω0t) − bv(t) − x(t) 􏰆 􏰅􏰄 􏰇
1