Download presentation
Presentation is loading. Please wait.
Published byKristin Randall Modified over 9 years ago
1
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 2 100Total 70 Written 30 Term Work 26 – 11 - 2015 Group Name
3
Books 3 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 3 rd Edition, O. BEUCHER and M. WEEKS Additional readings: Matlab help Matlab help Any useful tutorial, article or ppt on the web
4
Course Outline 4 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 5 9.Symbolic math.: integration and differentiation. 10. Simulink. 11.Control Systems. 12.Fluid Mechanics. Or Heat Transfer.
6
Agenda 6 Starting with Matlab: 1)Matlab Windows. 2)Arithmetic Operations. 3)Scalar Variables. 4)Introduction to m-files. 5)Examples.
7
Matlab Windows 7 Start Matlab from your programs list to have:
8
8 Matlab Windows
9
Command Window 9 Typing a command, using up/down arrows. Semicolon. ; Comments using % clc command. Command history window.
10
Arithmetic Operations 10
11
11 Order of precedence: Use MATLAB as a Calculator ! Arithmetic Operations
12
12 Display Format:
13
13 Math Built-in Functions
14
14 Math Built-in Functions
15
15 Math Built-in Functions
16
Scalar Variables 16 Using the assignment operator = There are rules in naming variables. Variable_name = A numerical value, or a computable expression
17
17 Scalar Variables
18
Rules About Variable Names 18 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 19 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 20 Used in programming: Others : ans, pi, i, j, inf, Nan
21
M-files 21 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
22 M-files
23
23 M-files
24
24 It is better to run your m-file from the current folder M-files
25
Example 1 25 Verify: at Solution:
26
Example 2 26
27
Example 2 27 Solution: Try m-file !
28
Material & problems 28 We have covered Chapter 1 from Gilat. Problems you can try: 1--10, 27,39,40
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.