![Page 1: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/1.jpg)
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
![Page 2: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/2.jpg)
2
Evaluation
100 Total
70 Written
30 Term Work
26 – 11 - 2015Group Name
![Page 3: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/3.jpg)
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
![Page 4: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/4.jpg)
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.
![Page 5: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/5.jpg)
5
Course Outline
9. Symbolic math.: integration and differentiation.
10. Simulink.
11. Control Systems.
12.Fluid Mechanics. Or Heat Transfer.
![Page 6: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/6.jpg)
6
Agenda
Starting with Matlab:
1)Matlab Windows.
2)Arithmetic Operations.
3)Scalar Variables.
4)Introduction to m-files.
5)Examples.
![Page 7: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/7.jpg)
7
Matlab Windows
Start Matlab from your programs list to have:
![Page 8: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/8.jpg)
8
Matlab Windows
![Page 9: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/9.jpg)
9
Command Window Typing a command, using up/down arrows.
Semicolon. ;
Comments using %
clc command.
Command history window.
![Page 10: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/10.jpg)
10
Arithmetic Operations
![Page 11: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/11.jpg)
11
Order of precedence:
Use MATLAB as a Calculator !
Arithmetic Operations
![Page 12: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/12.jpg)
12
Arithmetic Operations
Display Format:
![Page 13: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/13.jpg)
13
Math Built-in Functions
![Page 14: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/14.jpg)
14
Math Built-in Functions
![Page 15: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/15.jpg)
15
Math Built-in Functions
![Page 16: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/16.jpg)
16
Scalar Variables
Using the assignment operator =
There are rules in naming variables.
Variable_name = A numerical value, or a computable expression
![Page 17: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/17.jpg)
17
Scalar Variables
![Page 18: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/18.jpg)
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).
![Page 19: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/19.jpg)
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.
![Page 20: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/20.jpg)
20
Predefined Variables and Keywords
Used in programming:
Others:
ans, pi, i, j, inf, Nan
![Page 21: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/21.jpg)
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.
![Page 22: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/22.jpg)
22
M-files
![Page 23: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/23.jpg)
23
M-files
![Page 24: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/24.jpg)
24
It is better to run your m-file from the current folder
M-files
![Page 25: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/25.jpg)
25
Example 1
Verify: at
Solution:
![Page 26: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/26.jpg)
26
Example 2
![Page 27: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/27.jpg)
27
Example 2
Solution:
Try m-file !
![Page 28: 1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept](https://reader030.vdocuments.site/reader030/viewer/2022032723/56649f585503460f94c7dcfb/html5/thumbnails/28.jpg)
28
Material & problems
We have covered Chapter 1 from Gilat.
Problems you can try:
1--10, 27,39,40