function [root_f,iter_f] = falseposition(f,xl,xu,precision)
% INPUTS:
% - f: function handle of the equation to be solved
% - xl: lower limit of the initial guess
% - xu: upper limit of the initial guess
% - precision: stopping criteria determined by the
%comparing the efficiencies of the different methods
%Lab 6 Task 5(b)
clear all;
close all;
clc;
%parameters for root finding
xl=120;
xu=165;
xi=120;
xi_1=110;
pert=0.01;
precision=0.0001;
%input the length of each link
a=1;
b=2;
c=4;
d=5;
t2=30;
% 0=(d/a
function y= euler(dydt,xrange,y0,h);
% [t,y] = euler(dydt,tspan,y0,h):
% uses Euler's method to solve an ODE
% input:
% dydt = function handle of the ODE, f(t,y)
% tspan = [<initial value>, <final value>] of independent variable
% y0 = initial value of d
%comparing the efficiencies of the different methods
%Lab 6 Task 5(b)
clear all;
close all;
clc;
%parameters for root finding
xl=120;
xu=165;
xi=120;
xi_1=110;
pert=0.01;
precision=0.0001;
%input the length of each link
a=1;
b=2;
c=4;
d=5;
t2=30;
% 0=(d/a
ENG1060 Computing for Engineers
Faculty of Engineering
Semester 1 - 2014
ENG1060 Computing for Engineers
Laboratory No. 8
This laboratory comprises 2% of your final grade. During your lab session,
you will be assessed on your programming style as well as
ENG1060 Computing for Engineers
Faculty of Engineering
Semester 1 - 2014
ENG1060 Computing for Engineers
Laboratory No. 9
This laboratory comprises 2% of your final grade. During your lab session,
you will be assessed on your programming style as well as
ENG1060: Computing for Engineers
Faculty of Engineering
ENG1060: Computing for Engineers
2016 - Semester 2
Laboratory #4: Questions
This laboratory comprises 2% of your final grade. The questions are designed to test your
recollection of the lecture mater
MONASH
ENGINEERING
ENG1060
VARIABLE SCOPE
Presented by Tony Vo
Slides by Tony Vo
ENG1060
VARIABLE SCOPE
Variable scope governs where variables live
MATLAB does this using two workspaces
Base workspace
Function workspace
Where is the variable g after you
MONASH
ENGINEERING
ENG1060
FUNCTION HANDLES AND
ANONYMOUS FUNCTIONS
Presented by Tony Vo
Slides by Tony Vo
ENG1060
FUNCTION HANDLES
A function handle is a variable that represents a function
It provides a link between a variable and a function
Data Type
MONASH
ENGINEERING
ENG1060
EFFICIENT CODING
Presented by Tony Vo
Slides by Tony Vo
ENG1060
EFFICIENT CODING
When you start dealing with complex and large problems, speed is important
Make sure your code is correct and well documented before making it fas
MONASH
ENGINEERING
ENG1060
Ordinary Differential Equations (ODEs):
Introduction
Presented by Prof. Murray RUDMAN
Slides by M. Rudman
ENG1060
ODEs: Introduction
Many fundamental laws of physics, mechanics, electro-magnetism, chemical
reactions are framed
MONASH
ENGINEERING
ENG1060
ODEs: Other solvers
Presented by Prof. Murray RUDMAN
Slides by M. Rudman
ENG1060
ODEs: Classical 4th order Runge-Kutta Method (RK4)
Still solving the ODE
dy
= f t, y
dt
( )
k1 = f (ti , yi )
!
k1h $
h
k2 = f # ti + , yi +
&
2
2
MONASH
ENGINEERING
ENG1060
ODEs: Heuns method
Presented by Prof. Murray RUDMAN
Slides by M. Rudman
ENG1060
ODEs: Heuns method
Karl Heun (1859-1929)
German mathematician
Famous for:
Heuns function
Heuns equation
Heuns method
2
ENG1060
ODEs: Heuns met
MONASH
ENGINEERING
ENG1060
ODEs: Error in Eulers method
Presented by Prof. Murray RUDMAN
Slides by M. Rudman
ENG1060
ODEs: Error in Eulers method
We saw previously from the Taylors series
dy
h2 d 2 y
y(ti + h) = y ti + h
+
+!
dt t=t 2 dt 2 t=t
i
()
i
yi+
ENG1060: COMPUTING FOR ENGINEERS
Lab 1 week 2
2017 S1
This laboratory comprises 2% of your final grade. The questions are designed to test your
recollection of the lecture material. You will be assessed during your laboratory session by the
demonstrators.
% Written by: Amanda Veljanovski, ID: 28824199
% Last modified on : 6/03/2017
clear all; close all; clc;
%
a
b
c
abs : Absolute value
= abs(-5)
= [-1.3, 3, -5]
= abs(b)
% cosd : Cosine of argument in degrees
d = cosd(90)
e = [27i + 22]
f = cosd(e)
% mod :
MONASH
ENGINEERING
ENG1060
DEBUGGING
Presented by Tony Vo
Slides by Tony Vo
ENG1060
DEBUGGING
Debugging is the task of identifying and correcting errors (bugs) in code
Sometimes, identifying a bug is much more time consuming and challenging
than writing t
MONASH
ENGINEERING
ENG1060
MATLAB LIMITATIONS
Presented by Tony Vo
Slides by Tony Vo
ENG1060
ENG1060
MATLAB is not the focus of ENG1060!
MATLAB is only the tool
Your level of MATLAB is almost on par with mine now
Unit learning outcomes:
Part A: To deve
MONASH
ENGINEERING
ENG1060
DATA TYPES AND LIMITATIONS
Presented by Tony Vo
Slides by Tony Vo
ENG1060
THE DETAILS ARE IMPORTANT
MATLAB is a powerful tool for engineering computing but it has limitations
Engineers need to know the advantages and limitations
MONASH
ENGINEERING
ENG1060
ADVANCED FUNCTIONS
Presented by Tony Vo
Slides by Tony Vo
ENG1060
NOTICE
Some students dont know
That the video slides are available on Moodle
You do not need to watch the re-watch the videos just to look through slides
2
ENG
MONASH
ENGINEERING
ENG1060
SUB-FUNCTIONS
Presented by Tony Vo
Slides by Tony Vo
ENG1060
RECALL: HOW TO CREATE A FUNCTION FILE
Start a new m-file (script file)
Declare it as a function with a function header
The function header declaration
function output
clear all; close all; clc;
a = 1.5
w = 100
sigma = 17
beta = (pi*a)/(2*w)
f = sec(beta)*(tan(beta)/(beta)^0.5)*(0.752+2.02*(a/w)+0.37*(1-sin(beta)^3)
k = f*sigma*(sqrt(pi*a)
MONASH
ENGINEERING
ENG1060
WELCOME TO ENG1060:
COMPUTING FOR ENGINEERS
Presented by Tony Vo
Slides by Tony Vo
ENG1060
MATLAB
Use MATLAB to
Think as an engineer
Develop problem solving techniques
Understand commonly used numerical methods
Create and visual
MONASH
ENGINEERING
ENG1060
MATRIX CALCULATIONS
Presented by Tony Vo
Slides by Tony Vo
ENG1060
SCALAR VS. MATRIX CALCULATIONS
Basic scalar operators include: + - * / ^
E.g. 5*6 = 30
However, these are not necessary the same for matrix calculations
E.g. M
MONASH
ENGINEERING
ENG1060
MATRICES: CREATING 2D MATRICES
Presented by Tony Vo
Slides by Tony Vo
ENG1060
CREATING 2D MATRICES
A two-dimensional matrix contains multiple rows and columns
Use square brackets [ ] to create a two-dimensional matrix
MATLAB re
MONASH
ENGINEERING
ENG1060
PLOTTING DATA
Presented by Tony Vo
Slides by Tony Vo
ENG1060
PLOTS
Visualising the data allows you to interpret more information and more
quickly
Easier to characterise trends
I.e. Is it increasing or decreasing with increasing