Workshop
[time,q] = solver(@ODEFunction,timespan,q0)
Code: BallBounce1D_SingleBounce.m
Solving ODEs – Example
No definition of what the ground is so the ball flies
right through it
1D Ball Bounce with no Termination Callout
200
100
0
Y-Position of Ball
-100
-200
-300
-400
0 5 10 15
Time (sec)
Solving ODEs – Events
With ODE’s you can add events such that the
integration will stop if either the event is reached OR
the timespan reaches the last time entry
Now the integrator will stop every time the event is reached
and we can define a new q0 for the next bounce.
Solving ODEs – Events Output
Code: BallBounce1D_10Bounces.m
1D Ball Bounce with Termination Callout
140
Integration Points
120 Ball Bounce Points
100
Y-Position of Ball
80
60
40
20
-20
0 10 20 30 40 50 60 70
Time
Solving ODEs – Events Output
Code: BallBounce1D_10Bounces.m
1D Ball Bounce with Termination Callout
50
Integration Points
40 Ball Bounce Points
30
20
Y-Velocity of Ball
10
-10
-20
-30
-40
-50
0 10 20 30 40 50 60 70
Time
PDE Solvers
Solving PDEs
Even in MATLAB PDEs can be challenging
𝜕𝑢
Boundary Conditions: 𝒑 𝒙, 𝒕, 𝒖 + 𝒒 𝒙, 𝒕 𝑓 𝑥, 𝑡, 𝑢, =0
𝜕𝑥
𝑢 0, 𝑡 = 0
BC: 𝜕𝑢
−𝑡
𝜋𝑒 + (1, 𝑡)
𝜕𝑥
Fourier Transforms
Fourier Transform
MATLAB has a Fourier Transform tool to go between
time and frequency domain
http://www.mathworks.com/help/matlab/math/four
ier-transforms.html
Y = fft(Input array,n,dim)
Code: sunspot.m
Fast Fourier - Exercise
In scientific applications, signals are often corrupted
with random noise disguising their frequency
Fast Fourier - Exercise
In scientific applications, signals are often corrupted
with random noise disguising their frequency
Code: noisySignal.m
Optimization Toolbox
Optimization Toolbox
Provides functions for finding parameters that
minimize or maximize objectives while satisfying
constraints
options = optimoptions(@fmincon,...
'Display','iter','Algorithm','interior-point');
[x,fval] = fmincon(@rosenbrock,[0 0],...
[],[],[],[],[],[],@unitdisk,options)