You are on page 1of 40

Advanced Mathematical Methods

for Civil Engineering Applications

Wonsiri Punurai, PhD

Department of Civil Engineering


Room 6391, EG Building 3
Faculty of Engineering, Mahidol University
Personal Web: www.egmu.net/~civil/wonsiri

Course Information
z
z

Introduction to computer applications in civil


engineering.
Emphasis on analysis, mathematical
problem-solving skills with computer tools
and hand techniques.

Course Goals
At the end of this course, students will be able to
z Use, create, and modify scripts in MATLAB
(and probably spreadsheets in MS EXCEL) to
solve quantitative simple problems in future
classes.
z Prepare oral + written presentations in class

Conduct of Course
z

Homework/Projects/Quizzes

Midterm Exam

Final Exam

30 %
30 %
40 %

Warnings!!
z
z
z
z
z
z

Participation expected, check by quizzes


Study in groups but submit work on your own
No Copying of Matlab code
Submit Homework at the beginning of class
Late homework with penalty
No make up quizzes or exams

Computers as engineering tools


z

Productivity

Precision

One engineer can do the work for many.


If use properly computers offer solutions to many
engineering problems

Better communication

Visualization

Lecture I- Introduction to MATLAB

What is MATLAB?

Reference: www.mathworks.com

MATLAB 101
z

Getting Started ( )

Basic Arithmetic ( )

Built-in Functions ( )

Built-in Variables ( )

Getting Started

MATLAB101
MATLAB101--Getting
Getting Started
Started

Launch Pad
Command
Window

Command
History

MATLAB101
MATLAB101--Getting
Getting Started
Started

MATLAB101
MATLAB101--Getting
Getting Started
Started

MATLAB101
MATLAB101--Getting
Getting Started
Started

MATLAB101
MATLAB101--Getting
Getting Started
Started

MATLAB101
MATLAB101--Getting
Getting Started
Started

MATLAB101
MATLAB101--Getting
Getting Started
Started

Basic Arithmetic
z

Calculator functions work as youd expect:

+ and - are addition, / is division, * is multiplication, ^ is an exponent.

MATLAB101
MATLAB101--Basic
Basic Arithmetic
Arithmetic

Basic Arithmetic (cont.)

MATLAB101
MATLAB101--Basic
Basic Arithmetic
Arithmetic

MATLAB101
MATLAB101--Basic
Basic Arithmetic
Arithmetic

MATLAB101
MATLAB101--Basic
Basic Arithmetic
Arithmetic

MATLAB101
MATLAB101--Basic
Basic Arithmetic
Arithmetic

MATLAB 102
z

Array/Matrix ( )

How to save & load data ( )

Low level input & output

Graphics

Array/Matrix
z

A matrix is a rectangular array of numbers.


Scalars = 1x1 matrices
Vectors = row x column matrices

Lets try create a matrix A here!!

MATLAB102
MATLAB102--Array
Array

Steps to create a matrix


z

Separate the elements of a row with blanks or commas.

Use a semicolon, ; , to indicate the end of each row.

Surround the entire list of elements with square brackets, [ ] .

To check array dimension (no. of rows and columns) use a command whos

MATLAB102
MATLAB102--Array
Array

MATLAB102
MATLAB102--Array
Array

MATLAB102
MATLAB102--Array
Array

MATLAB102
MATLAB102--Array
Array

MATLAB102
MATLAB102--Array
Array

MATLAB102
MATLAB102--Array
Array

Quiz I

; Compute Y = Ab

Solution

MATLAB102
MATLAB102--Array
Array

Save & Load Data

MATLAB102
MATLAB102--Save/Load
Save/Load Data
Data

Input/Output Functions

MATLAB102
MATLAB102--In/Output
In/Output

MATLAB102
MATLAB102--In/Output
In/Output

Graphics
z

First, making a window for graphics output by


typing

Simply type plot in command window.


The plot function has different forms,
depending on input arguments.

Graphics (cont.)

Graphics create multiple data sets in one graph


z

MATLAB has ability to create multiple graphs.

Graphics specify line styles and colors

Lets try this!!

Graphics multiple plots in one figure

Graphics plotting examples

semilog plot

barplot

stair plot

loglog plot

Quiz II
z

Given y =sin (x1.8) where 0<x<0.5 and x increments every 0.05,


try plotting graph between x and y values now!!