+ All Categories
Home > Documents > EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

Date post: 20-Jan-2016
Category:
Upload: eustace-stevenson
View: 220 times
Download: 3 times
Share this document with a friend
26
EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015
Transcript
Page 1: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

EECS 1541

Introduction to Computing for the Physical Sciences

Winter 2015

Page 2: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

Instructor: John Lam

Office: Lassonde Building 1012G

E-mail: [email protected]

Lecture: Tuesday & Thursday 2:30 – 3:30pm

Office hours: Wednesday & Thursday 3:30pm – 4:30pm

22

Introduction – Course Overview

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 3: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

Course website: http://www.eecs.yorku.ca/course_archive/2014-15/W/1541/

33

• There are 8 labs in total (3% each)

• Labs start next Tuesday (Jan 13)

Introduction – Course Overview

• 2 term tests (20% each)

• Final exam (36%)

Please setup your CSE account and have it ready by next Tuesday!

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 4: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

44

How to do well in the course?

•Do all the labs (3% each!)

Introduction – Course Overview

• Attend lectures

• Do not skip the tests

• Read the text and study lecture notes

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 5: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

55

• This is an introductory course on computing for physical sciences using MATLAB

• What is MATLAB (MATrix LABoratory)?

Software program for technical computing, it combines computation, visualization and programming.

Introduction – MATLAB

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 6: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

66

• Computation: computes value from complex equations; solving a single equation or a system of equations

• Visualization: plots different types of 2-D graphs, 3-D contours

• Progamming: creates conditional statements or small programs such as using “if-statement”, “while-loop”, “for-loop”, etc.

Introduction – MATLAB

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 7: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

77

• Computation: computes value from complex equations; solving a single equation or a system of equations

• Visualization: plotting different types of 2-D graphs, 3-D contours

Progamming: create conditional statements or small programs such as using if-loop, while-loop, for-loop

Introduction – MATLAB

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 8: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

88

Introduction – MATLAB (Example 1)

• Recall that a linear equation with slope m and y-intercept b is given by:

bmxy

• Suppose the y-intercept b is zero and the slop is 3/2, and we want to plot the equation for -3 ≤ x ≤ 3:

xy2

3

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 9: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

99

Introduction – MATLAB (Example 1)

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 10: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1010

Introduction – MATLAB (Example 1)

-3 -2 -1 0 1 2 3-5

-4

-3

-2

-1

0

1

2

3

4

5

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 11: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1111

Introduction – MATLAB (Example 1)

• Suppose a parabola w is plotted on the same graph with the previous linear function and we want to determine the x-coordinates of the intersection points

2

3

2xw

xy2

3

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 12: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1212

Introduction – MATLAB (Example 1)

-3 -2 -1 0 1 2 3-6

-4

-2

0

2

4

6

x = 0

Approx. x = 2.4

EECS 1541 -- Introduction to Computing for the Physical Sciences

Can we determine the exact x-coordinate?

Page 13: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1313

Introduction – MATLAB (Example 1)

• Alternatively, we can equate the two equations and solve for x from MATLAB to determine the exact points:

02

3

3

2 2 xx

xx2

3

3

2 2

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 14: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1414

Introduction – MATLAB (Example 1)

EECS 1541 -- Introduction to Computing for the Physical Sciences

Solutions: x = 0 or 9/4 (i.e. 2.25)

Page 15: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1515

Computation: computes value from complex equations; solving a single equation or a system of equations

• Visualization: plotting different types of 2-D graphs, 3-D contours

• Progamming: create conditional statements or small programs such as using if-loop, while-loop, for-loop

Introduction – MATLAB

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 16: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1616

Introduction – MATLAB (Example 2)

• A periodic symmetrical square wave can be represented by the Fourier Series representation:

,...5,3,1

sin14

n

nxn

y

• Let’s plot the above series that consists of the first 3 terms for 0 ≤ x ≤ 2π:

xxxy 5sin5

43sin

3

4sin4

EECS 1541 -- Introduction to Computing for the Physical Sciences

x

y

. . . . . .

Page 17: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1717

Introduction – MATLAB (Example 2)

0 1 2 3 4 5 6 7-1.5

-1

-0.5

0

0.5

1

1.5

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 18: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1818

Introduction – MATLAB (Example 2)

• We can see that the graph is not really a perfect square wave, this is because we only used 3 of the terms in the Series.

• Instead of typing each term into MATLAB, we can use a “for-loop” to create the series to include “n” terms in the Series:

nxn

xxxy sin4

......5sin5

43sin

3

4sin4

EECS 1541 -- Introduction to Computing for the Physical Sciences

• We can increase the “resolution” of the square wave by including more terms in the Series.

Page 19: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

1919

Introduction – MATLAB (Example 2)

EECS 1541 -- Introduction to Computing for the Physical Sciences

A “for-loop” is used to implement the Series

Page 20: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

2020

Introduction – MATLAB (Example 2)

0 1 2 3 4 5 6 7-1.5

-1

-0.5

0

0.5

1

1.5

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 21: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

2121

Introduction – MATLAB (Example 2)

• We can put the 2 graphs on the same plot for comparison.

0 1 2 3 4 5 6 7-1.5

-1

-0.5

0

0.5

1

1.5

x

y

with 100 termswith 3 terms

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 22: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

2222

Introduction – MATLAB (Example 2)

• Essentially, the Fourier Series consists of terms with different frequencies.

nxn

xxxy sin4

......5sin5

43sin

3

4sin4

• We are interested to see the amount of harmonics in this series.

EECS 1541 -- Introduction to Computing for the Physical Sciences

• The first term is called fundamental component and the rest of the terms are called the harmonics.

Fundamental component

nxn

xxyharmonics sin4

......5sin5

43sin

3

4

Page 23: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

2323

Introduction – MATLAB (Example 2)

0 1 2 3 4 5 6 7-1.5

-1

-0.5

0

0.5

1

1.5

x

y

Fourier Series with 100 termsFundamental termHarmonics

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 24: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

2424

Introduction – MATLAB (Example 3)

• The previous example shows a type of built-in function in MATLAB (i.e. the sin function)

• You can create your own function in MATLAB and use it anytime.

• Suppose we want to create a function that is called “vol_cylinder.m”.

• This function will calculate the volume of a cylinder based on two input parameters: radius, height.

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 25: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

2525

Introduction – MATLAB (Example 3)

EECS 1541 -- Introduction to Computing for the Physical Sciences

Page 26: EECS 1541 Introduction to Computing for the Physical Sciences Winter 2015.

2626

Introduction – Matlab (Example 3)

EECS 1541 -- Introduction to Computing for the Physical Sciences


Recommended