0% found this document useful (0 votes)
9 views5 pages

AERO2598 Matlab Assignment 1-2 Slides

Uploaded by

Wong Siu Lam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

AERO2598 Matlab Assignment 1-2 Slides

Uploaded by

Wong Siu Lam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Simulation and Optimisation in Engineering

(AERO2598)
Assignment 1.2: Matlab Functions - Surface
Derivatives and Plotting
Co-ordinator: Dr Yidan Shang
Room 251.3.57
School of Engineering
Bundoora East Campus
Email: [email protected]

COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969


WARNING This material has been reproduced and communicated to you by or on behalf of
Royal Melbourne Institute of Technology, (RMIT University) pursuant to Part VB of the
Copyright Act 1968 (the Act). The material in this communication may be subject to
copyright under the Act. Any further reproduction or communication of this material by you
MECENG 743: Composite Materials
may be the subject of copyright protection under the Act. Do not remove this notice.
1

Submission Instructions
• You will be provided with two MATLAB files:
Main_Test_Script_surface_derivative.m
(You should not submit this file. This is the main script you will use to test
your function)
LastName_StudentID_surface_derivative.m
(Submit this file named with your last name and student ID. Make sure to
also modify the function name within the scripts)

• Use the templates provided to you through Canvas.


• Don’t zip the files.
• You should not submit any code related to the Tutorial2, only the Assignment1
codes.
• Failure to submit the assessment solution file through Canvas before the end of
submission date and time, will need special consideration approval from coordinator
to re-submit (with reasonable explanation). In that case, RMIT policy
of late assignment submission will apply (10% deduction of marks for each day delay)

RMITUniversity AERO2598 2
Assignment objectives
We consider a 2 variables function z=f(x,y). The general objectives are as follow:

• To evaluate this function over a range of x and y values, to display the output as a 3D
plot and find Maximum and Minimum values.

• To evaluate the partial derivative డ௙ൗడ௫ and డ௙ൗడ௬ over the same range of x and y
values and to display the output, together with Maximum and Minimum values.

Potential applications: plot mode shapes a vibrating panel or membrane.

RMITUniversity AERO2598 3

Assignment Tasks
1. Create a Matlab function which displays a surface plot for a given mathematical
function defined as an anonymous function.
2. Determine the partial derivative using numerical methods (not symbolical) and
plot the results in a 3 dimensional graph.
3. Correctly label any charts and graphs (axes labels, titles, etc.)
4. Determine and display on your graphs the location of the maximum/minimum values
by using a marker.
5. Provide the coordinates of the maximum and minimum values to the user as
three arrays.

RMITUniversity AERO2598 4
MainScript
Program Flow

Declarevariables

Defineananonymousfunction
Command
Window

Displayedoutput

RMITUniversity AERO2598 5

Function Input Arguments


[minmax1Z,minmaxDX,minmaxDY]=LastName_StudentID_surface_derivative
(xlims,ylims,nx,ny,myfun)

IMPORTANT!!–Donotredefinetheinput/outputterms.

Name Type Explanation

xlims Vectoroflength2 Minimumandmaximumxvaluesfortheplot.

ylims Vectoroflength2 Minimumandmaximumyvaluesfortheplot.

nx Scalar Numberofpointstoplotinthexdirection.

ny Scalar Numberofpointstoplotintheydirection.

myfun Anonymousfunction Functionthatwillbeplotted.

RMITUniversity AERO2598 6
Function Output Arguments
[minmax1Z,minmaxDX,minmaxDY]=
LastName_StudentID_surface_derivative(xlims,ylims,nx,ny,myfun)

Name Type Explanation


Firstrow:xandypositionofthefunction’sminimum.
minmax1Z 2×2matrix Secondrow:xandypositionofthefunction’smaximum.

Firstrow:xandypositionoftheminimumofthefunction’s
partialderivativewithrespecttox.
minmaxDX 2×2matrix
Secondrow:xandypositionofthemaximumofthefunction’s
partialderivativewithrespecttox.

Firstrow:xandypositionoftheminimumofthefunction’s
partialderivativewithrespecttoy.
minmaxDY 2×2matrix Secondrow:xandypositionofthemaximumofthefunction’s
partialderivativewithrespecttoy.

NOTE:Iftherearemultipleminima/maxima,youonlyneedtofindandreturnthecoͲordinates ofone.
7
RMITUniversity AERO2598

Matlab Knowledge Required


• Define an anonymous function
• Working with Matrices and Vectors
• Generate a linearly spaced vector (linspace(a,b))
• Generate grid of points (meshgrid(x,y))
• Evaluate the function on a defined grid
• 3D plotting (mesh(X,Y,Z) or surf(X,Y,Z))
• Label and title of plots (xlabel(), ylabel(), title())
• Evaluate maximum and minimum of the values (max() and min())
• Determine the corresponding x and y position using X_max=X(Z==Z_max)
• Display a single point on the 3D plot using a specific marker
(scatter(x,y,z,’r*’))

• Evaluate NUMERICALLY a partial derivative using the following equation, where ߲‫ݔ‬
is a small number.
డ௙ ௫ǡ௬ డ௙ ௙ ௫ାఋ௫ǡ௬ ି௙ሺ௫ǡ௬ሻ
ൎ ൌ 
డ௫ డ௫ ఋ௫

You must not attempt to calculate the derivative symbolically.


RMITUniversity AERO2598 8
Tips and recommendations
• Declare ߲‫ ݔ‬as a small value of your choosing
• For the partial derivative, calculate each part separately:
A=myfun(x+dx,y)
B=myfun(x,y)
Then the partial derivative against x is given by (A-B)/dx

• Validate your code on simple 1D line first, then extend to 2D.

• You MUST use and manipulate arrays instead of for and while loops.

RMITUniversity AERO2598 9

Marking Guidelines

Correctly plots the function 40%


Correctly plots the derivatives 30%
Correctly plots and returns min/max values 30%

Uses loops -25%


Evaluates derivatives symbolically -25%
Incorrect function definition or re-defines input -25%
values in function
Failure to follow coding instructions -25%

RMITUniversity AERO2598 10

You might also like