+ All Categories
Home > Documents > Overheads Day 4

Overheads Day 4

Date post: 02-Apr-2018
Category:
Upload: priyanksadasivuni
View: 218 times
Download: 1 times
Share this document with a friend
22
7/27/2019 Overheads Day 4 http://slidepdf.com/reader/full/overheads-day-4 1/22 Introduction to MATLAB Chris Diduch University of New Brunswick January 31 – February 4, 2004 Royal Bhutan University RBIT, Rinchending Day-4
Transcript
Page 1: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 1/22

Introduction toMATLAB

Chris DiduchUniversity of New Brunswick

January 31 – February 4, 2004

Royal Bhutan University

RBIT, RinchendingDay-4

Page 2: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 2/22

Interpolation

 x x f   y x ),(,

i x

Interpolated values are f ( xi)

 x

Page 3: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 3/22

Interpolation

)0()0( y y

 f t 

 x

)()(  f   f   t  yt  y

Page 4: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 4/22

Nonlinear Algebraic Equations

1)(

1)(

  

 

 j

e j P 

 s

e s P 

 j s

0)(Im   j P 

Page 5: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 5/22

Pendulum Dynamics

0sin 2     ml  Bmgl 

mg 

θ 

2

122

21

21

sin

,,:

ml 

 xmgl  Bx x

 x x x x Let 

  

Page 6: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 6/22

The MATLAB Programming

Language: Days 1-2

Matlab windows

 Arrays: create, append, index

Matrix and element-by-element operations Functions and scripts

Relational and logical operations

Structured programming: if, while, do, switch Basic plotting

Page 7: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 7/22

Data Analysis: Day 3

Solving linear equations

Eigenvalues and eigenvectors

Linear algebra Linear least sqares problems

Polynomials: multiply, divide, evaluate,

residues and roots. Curve fitting.

Numerical integration.

Page 8: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 8/22

Data Analysis: Day 3

Interpolation

Solving nonlinear algebraic equations

Finding the minimum value of a function Numerical solution to ODE’s 

Sound and audio

Page 9: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 9/22

Proposed Topics for Day-4

2-D Graphics

3-D Graphics

 Animation Simple GUI’s 

Page 10: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 10/22

Overlaying Plots

 plot() with multiple data sets

hold on, multiple plot()’s, hold off 

Create a new figure() window Use subplot()

Use the low level primitive, line()

Page 11: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 11/22

2D Plots

Plot functions

Semilog and loglog plots

Polar plots Filled plots, Pie and Bar charts, Histograms

Error bar 

Step and staircase Comet

Contour and quiver plots

Page 12: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 12/22

3D Plots

Plot a line in 3D, plot3()

Polygons in 3D

Contour plots Surface plots

Interpolated surface plots

Shapes: sphere, ellipsoid, cylinder 

Page 13: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 13/22

Handle Graphics

Each object in a fig window is assigned and

identified by a number called its handle.

Objects are related through a hierarchy.

Objects have a set of default properties.

The properties may be changed using set()

Page 14: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 14/22

Example

t=linspace(0,pi,50)

x=t.*sin(t)

hL=line(t,x)get(hL)

set(hL,'linestyle','--')

Page 15: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 15/22

MATLAB Object Hierarchy

Figure

Uicontrols  Axes Uimenus

Line Patch Text Image

Page 16: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 16/22

Graphics and Animation

line() % Create line object

set() % Update object

% attributes drawnow() % Update figure window

clock % Return current time

etime() % Return elapsed time

Page 17: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 17/22

An Orbiting Dot

Page 18: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 18/22

Animate a Phasor 

 sin ωt 

Page 19: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 19/22

Multiple Axes in the same

Figure Window

HandleAx = AXES('position', RECT)

Opens up an axis at the position, RECT. RECT = [left, bottom, width, height]

Relative to the lower-left corner of the Figwindow, in normalized units.

(0,0) is the lower-left corner and (1.0,1.0) isthe upper-right.

Page 20: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 20/22

Animate the Pendulum

Page 21: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 21/22

Pendulum Animation

 Animation updates are

governed by the laws of 

motion.

Euler’s method gives: 

2

111

1

sin

ml 

mgl  B

k k k k k 

k k k 

     

   

Page 22: Overheads Day 4

7/27/2019 Overheads Day 4

http://slidepdf.com/reader/full/overheads-day-4 22/22

Animate the Pendulum-2

ω vs t ω vs θ  

θ vs t  Animation


Recommended