Sie sind auf Seite 1von 26

Engineering Programming and Computation

using

MATLAB

Cheng-Liang Chen
PSE
LABORATORY
Department of Chemical Engineering
National TAIWAN University
Chen CL 1

Engineering Programming and Computation


using

MATLAB

Teacher: Cheng-Liang Chen


CCL@ntu.edu.tw
Assistant: Jui-Yuan Lee
f95524063@ntu.edu.tw
Chen CL 2

Textbook and Reference

William J. Palm III


Introduction to MATLAB 7 for Engineers

Michael B. Cutlip and Mordechai Shacham


Problem Solving in Chemical and Biochemical Engineering . . .
Chen CL 3

Table of Contents
➢ MATLAB and Problem Solving
➢ Plotting and Model Building
➢ Array and Matrix Operations
➢ Files, Functions, and Data Structures
Formatted Output in MATLAB
➢ Programming with MATLAB
➢ Linear Algebraic Equations
➢ Probability, Statistics, and Interpolation
➢ Numerical Calculus, Differential Equations, and Simulink
➢ Symbolic Processing with MATLAB
➢ Problem Solving in Chemical Engineering:
Basic Principles and Calculations; Thermodynamics; Reaction Engineering;
Phase Equilibrium and Distillation; (Fluid Mechanics; Heat Transfer;
Mass Transfer; Process Dynamics and Control; Biochemical Engineering)
Chen CL 4

Some Notes
➢ Teaching and designated exercise during class:
Wed 1 : 20 ∼ 3 : 10
Thu 1 : 20 ∼ 2 : 10
⇒ Wed 12 : 50 ∼ 3 : 10
➢ One or two student(s) per group
☞ Prepare one document file for each exercise designated during class:
B97504037
| {z } Ex01 1 . |{z}
| {z } |{z} doc
reg. # ex # version doc file
Document file should include title of this exercise, name(s) and registered
number(s), simple problem statement and main results, M-file, figure(s),
table(s), . . .
☞ E-mail your document file immediately to teaching assistant
(Lee, f95524063@ntu.edu.tw) before you leave computer room
☞ You can modify your report and e-mail it again to teaching assistant after
the class (use another file name: B97504037 Ex01 |{z} 2 .doc )
new
ver
➢ Examinations: 2 mid-terms and 1 final (25% + 25% + 25%)
Designated exercises and Performance during class: (25%)
Chen CL 5

Learning Objectives in
Engineering Programming
➢ We are not going to train you as a programmer or software
engineer

➢ Main learning objectives in this course:


To use computational tool(s) for solving engineering problems effectively

☞ Understand and analyze the problem


☞ Model formulation
☞ Solution method (analytical or numerical ?)
☞ Computer program for solving the problem

➢ Which programming language ? FORTRAN ? C++ ? . . .

No Magic, only BASIC


Chen CL 6

Milestones in Computer Science


BC 3000 Abacus China
1642 Blaise Pascal Pascaline (Frence, mathematician) a machine
for addition
1801 Joseph-Marie Jacquard loom use punched cards to control a
Jacquard machine
1822 Charles Babbage Difference simple computations
engine
1889 Herman A “machine” using punched cards for US
Hollerith population statistics (7.5 → 2.5
years)
1896 Herman Tabulating International Business Machines
Hollerith Machine Corporation (1924/2/14)
Company
1937 Alan Turing Turing (England) A prototype machine for
Machine digital computation
1938 William Hewlett- (Stanford, Palo Alto)
Hewlett, David Packard
Packard Company
Chen CL 7

Milestones in Computer Science


1939 John V. Atanasoff- Iowa State Univ. The 1st electronic
Atanasoff, Berry computer. Electrical signals for
Clifford Berry Computer information codes
1944 Havard Univ. Mark 1 A machine for automatic computation
(+ IBM) (8 × 51 ft2)
1945 John von Stored Basic concept for modern computer
Neumann program hardware
1946 John W. ENIAC Electronic Numerical Integrator And
Mauchly, J. Computer. The first vacuum tube
Presper Eckert computer (30 tons, 30 × 50 ft2).
Jr University of Pennsylvania.
1952 Grace Murray A-0 The first compiler
Hopper
1957 John Backus FORTRAN FORmula TRANslation language.
(IBM) The first high level computer
language.
Emphasize scientific programming
Chen CL 8

Milestones in Computer Science


1959 Honeywell Honeywell The first transistor-based computer
400
John McCarthy LISP (Carnegie-Mellon) A language for
symbolic computation
1963 USA Standard ASCII American Standard Code for
Bureau Information Interchange
1964 IBM IBM 360 The first integrated circuit computer
Douglas mouse
Engelbard
1965 MIT, Bell, GE Multics
Operating
System
1968 Noyce, Grove, Intel Central Processing Units: 4004, 8008,
Moore Company . . . Pentium . . .
1970 Dennis Ritchie, Unix OS
Kenneth
Thompson
Chen CL 9

Milestones in Computer Science


1971 Niklaus Wirth Pascal
Ray Tomlinson email
Intel Intel 4004 Microprocessor, Integrated Circuit
CPU
1972 Dennis Ritchie C language (from B)
1975 ? Altair 8800 The first personal computer
1976 Steve Jobs, Apple 1
Steve Wozniak
1977 Steve Jobs, Apple 2 Apple Company
Steve Wozniak
Bill Gates, Microsoft
Paul Allen
1978 Intel Intel 8086, (16 bits)
8088
1981 IBM IBM PC (→ IBM compatible PCs)
Chen CL 10

Milestones in Computer Science


1982 Intel Intel 80286 (16 bits)
1984 Sony, Philips CD-ROM
IBM IBM PC AT Use Intel 80286
1985 Microsoft Window 1.0
1986 Intel Intel 80386 (32 bits)
1989 Intel Intel 80486
Tim Berners-Lee World Wide (announced in 1990)
Web
1991 Linus Torvalds Linux Linus + Unix (Finland)
1993 Apple Personal
Digital
Assistant
Intel Pentium 60,
66 MHz
Microsoft Windows NT
Chen CL 11

Milestones in Computer Science


1994 ? Netscape
Young and YAHOO! Yet Anothher Hierarchical Officious
David Filo Oracle !
1995 James Gosling JAVA Java Coffee ?! (Sun)
Microsoft Windows 95 with Internet Explorer 1.0
1997 Intel Pentium II
1998 Microsoft Windows 98
Larry Page, Google (Stanford)
Sergey Brin
1999 Intel Pentium III,
Celeron
2000 Microsoft Windows 2000 98 → Windows Me (Millennium
(from NT) edition)
Intel Pentium 4
2001 Microsoft Windows XP (eXPerience, from Windows 95, NT)
2003 Intel Pentium M (Intel Centrino)
Chen CL 12

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)

1960

1965

1970

1975 01011010 ADD


Year

1980

1985

1990

1995

2000
Chen CL 13

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
FORTRAN
1960

1965

1970 DO 7, LOOP = 1,5


READ *, X, Y
AVE=(X+Y)/2.0
1975
Year

PRINT *, X,Y,AVE
7 CONTINUE
1980 END

1985

1990

1995

2000
Chen CL 14

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
FORTRAN
COBOL
1960

1965

1970 01 EMPLOYEE−RECORD
05 EMPLOYEE−NUMBER PIC 9(5)
05 EMPLOYEE−NAME PIC X(30)
1975
Year

05 BIRTH−DATE
10 BIRTH−MONTH PIC 99
1980 10 FILLER PIC X
10 BIRTH−DAY PIC 99
05 DATE−HIRED
1985
10 MONTH−HIRED PIC 99
10 FILLER PIC X
1990 10 DAY−HIRED PIC 99

1995

2000
Chen CL 15

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
LISP
FORTRAN
COBOL
1960

1965

1970 (defun length (x)


PROLOG (cond ((null x) 0)
(t(+1 (length (cdr x))))))
1975
Year

SCHEME (length ’(I Love Computers)’)


3
1980

COMMON
1985 LISP

1990
CLOS

1995

2000
Chen CL 16

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
LISP
FORTRAN
COBOL
1960

1965 BASIC

1970
PROLOG Dim i, sum

1975
Year

SCHEME sum = 0
For i = 1 to 10
1980 sum = sum + 1
Next i
COMMON
1985 LISP

1990
CLOS
VISUAL
1995 BASIC

2000
Chen CL 17

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
LISP
FORTRAN
COBOL
1960 ALGOL60

1965 BASIC

1970
PASCAL
PROLOG

1975
Year

SCHEME

1980 MODULA−2

COMMON if (i > 0) then


1985 LISP
x := 10
else
MODULA−3
1990 y := 5
CLOS
VISUAL
1995 BASIC

2000
Chen CL 18

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
LISP
FORTRAN
COBOL
1960 ALGOL60

CPL
1965 BASIC

1970
PASCAL
PROLOG C
1975
Year

SCHEME

1980 MODULA−2

COMMON if (i > 0)
1985 LISP
x = 10;
else
MODULA−3
1990 y = 5;
CLOS
VISUAL
1995 BASIC

2000
Chen CL 19

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
LISP
FORTRAN
COBOL
1960 ALGOL60

CPL
1965 BASIC
SIMULA
1970
PASCAL
PROLOG C
1975
Year

SCHEME

SMALLTALK
1980 MODULA−2

COMMON C++
1985 LISP

MODULA−3
1990
CLOS
VISUAL
1995 C++ BASIC
Standard

2000
Chen CL 20

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
LISP
FORTRAN
COBOL
1960 ALGOL60

CPL
1965 BASIC
SIMULA
1970
PASCAL
PROLOG C
1975
Year

SCHEME

SMALLTALK
1980 ADA MODULA−2

COMMON C++
1985 LISP

MODULA−3
1990
CLOS
VISUAL
1995 JAVA C++ BASIC
Standard

2000
Chen CL 21

Progress of Programming Languages

Progress of Programming Languages


1955
(Machine Language) (Assembly Language)
LISP
FORTRAN
COBOL
1960 ALGOL60

CPL
1965 BASIC
SIMULA
1970
PASCAL
PROLOG C
1975
Year

SCHEME

SMALLTALK
MATLAB
1980 ADA MODULA−2

COMMON C++
1985 LISP

MODULA−3
1990
CLOS
VISUAL
1995 JAVA C++ BASIC
Standard

2000
Chen CL 22

Some High-level Programming Languages


Summary

Language Date Application Area Origin of Names


FORTRAN IBM (1957) Scientific programming FORmula TRANslation language

LISP MIT (1958) Symbolic computation (AI) LISp Processing → Common Lisp Object System

COBOL USA (1959) Business data processing COmmon Business-Oriented Language

BASIC (1965) Simple on PC Beginner’s All Purpose Symbolic Instruction Code

C Bell (1972) Systems programming Predecessor language was named B

PROLOG (1972) Symbolic computation (AI) PROgramming LOGic (Frence)

Ada USA (1980) Real-time distributed systems Ada Augusta Byron collaborated with nineteenth-
century computer pioneer Charles Babbage

Smalltalk (1980) Graphical user interfaces; Objects “talk” to one another via messages
Object-oriented programming

C++ Supports objects and Incremental modification of C


Objected-oriented programming (++ is the C increment operator)

JAVA SUN (1995) Supports Web programming Originally named “Oak”


Chen CL 23

MATLAB ?

MATrixLABoratory
➢ In 1978, Professor Cleve Moler (New Mexico University, USA)
used FORTRAN to write the MATLAB for applications involving
matrices, linear algebra, and numerical analysis

➢ In 1984, Jack Little (Stanford University) used C to rewrite and


to commercialize the MATLAB software (MathWorks Company)

➢ MATLAB is both a computer programming language and


an interactive software environment for using that language
effectively
Chen CL 24

Why MATLAB ?
Outstanding Features
➢ Significantly simpler programming
➢ Continuity (no distinction) among integer, real, and complex values
(any variable can take any type of number without special declaration)

➢ Extended range of numbers and their accuracy


(all in double precision)
➢ Extensive graphic tools including graphic user interface functions
➢ A comprehensive mathematical library
➢ Capability of linking with traditional programming languages
➢ Transportability of MATLAB programs
➢ MATLAB has a number of add-on software modules, called
toolboxes, that perform more specialized computations.
All toolboxes run under the core MATLAB program
Chen CL 25

Thank You for Your Attention


Questions Are Welcome

Das könnte Ihnen auch gefallen