Upload
kristin-randall
View
215
Download
2
Embed Size (px)
Citation preview
1
Lecture 1
Post-Graduate Students
Advanced Programming (Introduction to
MATLAB)Code: ENG 505
Dr. Basheer M. Nasef
Computers & Systems
Dept.http://www.bmabdelaty.faculty.zu.edu.eg/Default.aspx
2
Evaluation
100 Total
70 Written
30 Term Work
26 – 11 - 2015Group Name
3
Books Main textbook: MATLAB® An Introduction with Applications, Fourth Edition, Amos Gilat.
An Engineer’s Guide to MATLAB With Applications from Mechanical, Aerospace, Electrical, Civil, and Biological Systems Engineering, Third Edition
INTRODUCTION TO MATLAB® & SIMULINK 3rd Edition, O. BEUCHER and M. WEEKS
Additional readings:
Matlab help
Any useful tutorial, article or ppt on the web
4
Course Outline
1. Starting with Matlab.
2. Arrays and Matrices.
3. Mathematical operations on arrays.
4. M-files and data I/O.
5. 2-D plots.
6. Programming in Matlab.
7. User defined functions.
8. Polynomials and curve fitting.
5
Course Outline
9. Symbolic math.: integration and differentiation.
10. Simulink.
11. Control Systems.
12.Fluid Mechanics. Or Heat Transfer.
6
Agenda
Starting with Matlab:
1)Matlab Windows.
2)Arithmetic Operations.
3)Scalar Variables.
4)Introduction to m-files.
5)Examples.
7
Matlab Windows
Start Matlab from your programs list to have:
8
Matlab Windows
9
Command Window Typing a command, using up/down arrows.
Semicolon. ;
Comments using %
clc command.
Command history window.
10
Arithmetic Operations
11
Order of precedence:
Use MATLAB as a Calculator !
Arithmetic Operations
12
Arithmetic Operations
Display Format:
13
Math Built-in Functions
14
Math Built-in Functions
15
Math Built-in Functions
16
Scalar Variables
Using the assignment operator =
There are rules in naming variables.
Variable_name = A numerical value, or a computable expression
17
Scalar Variables
18
Rules About Variable Names
A variable can be named according to the following rules:
1. Must begin with a letter.2. Can be up to 63 characters long.3. Can contain letters, digits, and the underscore
character.4. Cannot contain punctuation characters (e.g
period, comma, semicolon).
19
Rules About Variable Names
5. MATLAB is case sensitive: it distinguishes between uppercase and lowercase letters. For example, AA, Aa, aA, and aa are the names of four different variables.
6. No spaces are allowed between characters (use the underscore where a space is desired).
7. Avoid using the name of a built-in function for a variable (i.e., avoid using cos, sin, exp, sqrt, etc.). Once a function name is used to define a variable, the function cannot be used.
20
Predefined Variables and Keywords
Used in programming:
Others:
ans, pi, i, j, inf, Nan
21
M-files
A different (better) way of executing commands
with MATLAB is first to create a file with a list of
commands (program), save it, and then run
(execute) the file.
M-file is also called script file.
Using a script file is convenient because it can be
edited (corrected or otherwise changed) and
executed many times.
22
M-files
23
M-files
24
It is better to run your m-file from the current folder
M-files
25
Example 1
Verify: at
Solution:
26
Example 2
27
Example 2
Solution:
Try m-file !
28
Material & problems
We have covered Chapter 1 from Gilat.
Problems you can try:
1--10, 27,39,40