CS计算机代考程序代写 matlab algorithm ENGR20005

ENGR20005
Numerical Methods in Engineering
Workshop 1
Preliminaries: Installing and Learning MATLAB
1.1 MATLAB is a useful tool that you will use throughout your studies and also in the workplace. This subject will require you to use MATLAB to complete many tasks. You would need to install MATLAB on your own personal computer for this semester. Some of the MATLAB programs below do require you have to have the latest version of MATLAB. If you do not have the latest version of MATLAB, or if you have never installed MATLAB before, you can download and install from
https://studentit.unimelb.edu.au/software
Just click on the green “MATLAB Programming environment for scientists and engi- neers” button and follow the instructions.
1.2 We are aware that there are many students who are familiar with MATLAB but also many students who are not. To get through this subject we only require you to know the basics of MATLAB. We do not expect you to be an advance user in MATLAB. If you have not learnt MATLAB, or need to re-familiarize yourself with MATLAB, one website where you can learn MATLAB is the “MATLAB Onramp” course at
https://matlabacademy.mathworks.com/
You might need to give yourself an account on this website in order to use the program.
Part A: MATLAB Livescripts
1.3 The livescript ENGR20005 Workshop01p03.mlx demonstrates the use of variables and arrays in MATLAB. Work through this livescript and study how you can create arrays, access different elements of arrays and how to plot simple functions.
1.4 The livescript ENGR20005 Workshop01p04.mlx shows how you can obtain the Taylor series for cos(x). It also demonstrates that the Taylor series for cos(x) converges to cos(x) if we retain more and more terms of the Taylor series.
1

1.5 For many algorithms that will be introduced in this subject, you will need to perform repetitive calculations. This can be done very fast using a for loop in MATLAB. The livescript ENGR20005 Workshop01p05.mlx shows you how to use for loops to perform the repetitive.
1.6 The livescript ENGR20005 Workshop01p06.mlx shows you how to analyse the function f(x)=x2 −2x−1 (1.1)
and uses the MATLAB functions fzero() and roots() to find the roots of f(x), i.e. solve for the value(s) of x such that f(x) = 0. Read through this livescript and make sure you understand the purpose of line of code.
1.7 A skill that is often used in in many engineering applications is the visualisation of mul- tidimensional functions. livescript ENGR20005 Workshop01p07.mlx shows you how to use the relevant MATLAB functions to plot a function of two variables, f(x,y).
Part B: Problems
1.8 Follow the steps in the livescript ENGR20005 Workshop01p04.mlx and find the Taylor series for
f(x) = xex (1.2) Plot the Taylor series between −1 ≤ x ≤ 1 with more and more terms and show that
it converges to the function xex.
1.9 Using the code snippets in livescript ENGR20005 Workshop01p06.mlx, write a MAT-
LAB program (a .m file) to find the roots of the function f(x) = 50 􏰁1 − e−9x/5􏰂 − 10
x
using the fzero() function in MATLAB. 1.10 * Consider the function
f(x, y) = xe−((x−y2)2+y2)
(1.3)
(1.4)
(a) Using code that can be found in livescript ENGR20005 Workshop01p07.mlx, plot contours of the function f (x, y) = −0.2, −0.1, 0.0, 0.1, 0.2, 0.3 in the domain −3 ≤ x ≤ 3 and −3 ≤ y ≤ 3 .
(b) On a separate graph the contour line for just f(x,y) = 0.2.
(c) WriteaMATLABcodetoplotf(x=1,y)
(d) Use the fzero() function to find the value of y such that f(x = 1,y) = 0.2. Check your solution visually with the plot in part (b).
2