Você está na página 1de 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: Chih-Yao Lin
d96524003@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
Array and Matrix Operations
Files, Functions, and Data Structures
Programming with MATLAB
Plotting and Model Building
Linear Algebraic Equations
Probability, Statistics, and Interpolation
Numerical Calculus, Dierential 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:
Wednesday 1 : 20 3 : 10
Thursday 1 : 20 2 : 10 (option 1: each week)
1 : 20 3 : 10 (option 2: every 2 weeks)
One or two student(s) per group
Prepare one document le for each exercise designated during class:
B95524063

reg. #
EX01

ex #
1

version
. doc

doc le
Document le should include title of this exercise, name(s) and registered
number(s), simple problem statement and main results, M-le, gure(s),
table(s), . . .
E-mail your document le immediately to teaching assistant
(Lin, d96524003@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 le name: B95524063 -EX01 - 2

new
ver
.doc )
Examinations: 2 mid-terms and 1 nal (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 eectively
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
Jacquard loom use punched cards to control a
machine
1822 Charles Babbage Dierence
engine
simple computations
1889 Herman
Hollerith
A machine using punched cards for US
population statistics (7.5 2.5
years)
1896 Herman
Hollerith
Tabulating
Machine
Company
International Business Machines
Corporation (1924/2/14)
1937 Alan Turing Turing
Machine
(England) A prototype machine for
digital computation
1938 William
Hewlett, David
Packard
Hewlett-
Packard
Company
(Stanford, Palo Alto)
Chen CL 7
Milestones in Computer Science
1939 John V.
Atanaso,
Cliord Berry
Atanaso-
Berry
Computer
Iowa State Univ. The 1st electronic
computer. Electrical signals for
information codes
1944 Havard Univ.
(+ IBM)
Mark 1 A machine for automatic computation
(8 51 ft
2
)
1945 John von
Neumann
Stored
program
Basic concept for modern computer
hardware
1946 John W.
Mauchly, J.
Presper Eckert
Jr
ENIAC Electronic Numerical Integrator And
Computer. The rst vacuum tube
computer (30 tons, 30 50 ft
2
).
University of Pennsylvania.
1952 Grace Murray
Hopper
A-0 The rst compiler
1957 John Backus FORTRAN FORmula TRANslation language.
(IBM) The rst high level computer
language.
Emphasize scientic programming
Chen CL 8
Milestones in Computer Science
1959 Honeywell Honeywell
400
The rst transistor-based computer
John McCarthy LISP (Carnegie-Mellon) A language for
symbolic computation
1963 USA Standard
Bureau
ASCII American Standard Code for
Information Interchange
1964 IBM IBM 360 The rst integrated circuit computer
Douglas
Engelbard
mouse
1965 MIT, Bell, GE Multics
Operating
System
1968 Noyce, Grove,
Moore
Intel
Company
Central Processing Units: 4004, 8008,
. . . Pentium . . .
1970 Dennis Ritchie,
Kenneth
Thompson
Unix OS
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 rst personal computer
1976 Steve Jobs,
Steve Wozniak
Apple 1
1977 Steve Jobs,
Steve Wozniak
Apple 2 Apple Company
Bill Gates,
Paul Allen
Microsoft
1978 Intel Intel 8086,
8088
(16 bits)
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
Web
(announced in 1990)
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
David Filo
YAHOO! Yet Anothher Hierarchical Ocious
Oracle !
1995 James Gosling JAVA Java Coee ?! (Sun)
Microsoft Windows 95 with Internet Explorer 1.0
1997 Intel Pentium II
1998 Microsoft Windows 98
Larry Page,
Sergey Brin
Google (Stanford)
1999 Intel Pentium III,
Celeron
2000 Microsoft Windows 2000
(from NT)
98 Windows Me (Millennium
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
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
01011010 ADD
Chen CL 13
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
DO 7, LOOP = 1,5
READ *, X, Y
AVE=(X+Y)/2.0
PRINT *, X,Y,AVE
7 CONTINUE
END
Chen CL 14
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
01 EMPLOYEERECORD
05 EMPLOYEENUMBER PIC 9(5)
05 EMPLOYEENAME PIC X(30)
05 BIRTHDATE
10 BIRTHMONTH PIC 99
10 FILLER PIC X
10 BIRTHDAY PIC 99
05 DATEHIRED
10 MONTHHIRED PIC 99
10 FILLER PIC X
10 DAYHIRED PIC 99
Chen CL 15
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
(defun length (x)
(cond ((null x) 0)
(t(+1 (length (cdr x))))))
(length (I Love Computers))
3
Chen CL 16
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
Dim i, sum

sum = 0
For i = 1 to 10
sum = sum + 1
Next i
Chen CL 17
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
if (i > 0) then
x := 10
else
y := 5
Chen CL 18
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
if (i > 0)
x = 10;
else
y = 5;
Chen CL 19
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
SIMULA
SMALLTALK
C++
C++
Standard
Chen CL 20
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
SIMULA
SMALLTALK
C++
C++
Standard
ADA
JAVA
Chen CL 21
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
SIMULA
SMALLTALK
C++
C++
Standard
ADA
JAVA
MATLAB
Chen CL 22
Some High-level Programming Languages
Summary
Language Date Application Area Origin of Names
FORTRAN IBM (1957) Scientic 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 Beginners 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;
Object-oriented programming
Objects talk to one another via messages
C++ Supports objects and
Objected-oriented programming
Incremental modication of C
(++ 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
eectively
Chen CL 24
Why MATLAB ?
Outstanding Features
Signicantly 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

Você também pode gostar