MATLAB By Mohammed Sami Ashhab University of Jordan

MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008 University of Jordan “Moh’d Sami” Ashhab

What is MATLAB The name MATLAB stands for Matrix Laboratory. MATLAB is a matrix-based software system designed to assist in scientific, engineering and business problem solving. In this prsentation we will give you the opportunity to get accustomed with the use of MATLAB in addition to its applications and power. Information about the software can be found at the Math. Works web site http: //www. mathworks. com. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

What is MATLAB Summer 2008 University of Jordan “Moh’d Sami” Ashhab

What is MATLAB Summer 2008 University of Jordan “Moh’d Sami” Ashhab

MATLAB Applications Engineering Science Business Summer 2008 University of Jordan “Moh’d Sami” Ashhab

MATLAB Course Contents 1. Introduction 2. Vectors and Matrices 3. 2 D plots 4. 3 D plots 5. Scripts(m-files) 6. If statements 7. Loops 8. Functions (subroutines) 9. Experimental data analysis 10. Solution of linear differential equations 11. Solution of nonlinear differential equations 12. Handling files 13. Simulink Summer 2008 University of Jordan “Moh’d Sami” Ashhab

1. Introduction Starting Matlab Summer 2008 University of Jordan “Moh’d Sami” Ashhab

1. Introduction Assignment a=2 Arithmetic Operations a=b+c Special Symbols : Predefined Variables pi Built-in Functions abs Complex Numbers 3+4 i Useful Matlab Commands who Summer 2008 University of Jordan “Moh’d Sami” Ashhab

2. Vectors and Matrices are the backbone For MATLAB Matrix Definition Arithmetic Operations Matrix Array Operations Vectors and Colon Notation Special Matrices Block Matrices Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Matrix Applications Use of Built-in Functions Statistics Polynomial Roots Solving n Equations By n Unknowns Summer 2008 University of Jordan “Moh’d Sami” Ashhab

3. 2 D Plots Once you master Matlab basics, vectors and matrices, It becomes simple process to generate 2 -dimensional plots with MATLAB. It is possible to control the appearance of the plots and use them in other documents such as Microsoft word. Some of the plotting features are: - Curve color and style control - Axis labeling - Title Addition - Text Addition - Grid, axis and legend features Summer 2008 University of Jordan “Moh’d Sami” Ashhab

3. 2 D Plots Basic Function Plot Multiple Curves Customizing Plots Color and Style Grid and Axis Summer 2008 University of Jordan “Moh’d Sami” Ashhab

3. 2 D Plots Summer 2008 University of Jordan “Moh’d Sami” Ashhab

4. 3 D Plots Matlab enables you to display three dimensional information. Surface and contour plots are possible. One dimensional curves in the three dimensional space can be generated. Deep knowledge of matrix use is needed to setup data for the plot. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

4. 3 D Plots Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Subplots Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Subplots Summer 2008 University of Jordan “Moh’d Sami” Ashhab

5. Scripts (M-file) Matlab commands can be programmed and saved in a file like in C and Java. Creating an M-file Saving Running Naming Summer 2008 University of Jordan “Moh’d Sami” Ashhab

6. Logical Satements The logical statements are very important in programming Matlab. We will cover all the aspects that the user needs for logical statements such as syntax, if-statements and logical operators. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

7. Loops The loops are very important in programming Matlab. We will cover all the aspects that the user needs for loops such as syntax for and while loops and break statement. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

8. Functions (Subroutines) Matlab represents standalone functions in individual programs. The user can program his own functions and add them to the Matlab library. The user can use his subroutines anytime in the future once he/she has the stored in the Matlab libraries. Subroutines are essential for methods that require the solution of a function such as root finding and differential equations. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

9. Solution of Linear Differential Eqs Differential equations appear in most of the scientific, engineering and business applications. Matlab is a very powerful tool for the solution of linear differential equations. A Matlab user will solve the linear differential equations efficiently when he/she understands how to convert these equations into a matrix form. In the Matlab training course we will cover the basics of linear differential equations first and then Matlab will utilized to solve all types of linear differential equations. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

9. Solution of Linear Differential Eqs Summer 2008 University of Jordan “Moh’d Sami” Ashhab

10. Solution of Nonlinear Differential Eqs Nonlinear differential equations are very hard to solve analytically and therefore a computer program or software is needed. Most of the differential equations that are encountered in practical applications are nonlinear. Matlab is one of the best available softwares that can solve nonlinear differential equations efficiently and fast. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

11. Handling Files Matlab is able to extract data from files in formats such as excel, text, ascii and dat. Matlab generated data in Matlab is stored in the. mat (Matlab) format. Matlab allows the user to store the data in formats such as excel, text, ascii and dat. In summary, Matlab can exchange data in different formats and thus eliminating the need to entering the data by hand when it comes from other various sources. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

12. Simulink is a nice and powerful tool that represents a system as a block diagram. Each block represents a component of the system. These components are interconnected to form the block diagram. Block Diagrams are solved with Simulink. People usually prefer using Simulink over Matlab programming because it is easier to monitor and understand the system. Summer 2008 University of Jordan “Moh’d Sami” Ashhab

12. Simulink Summer 2008 University of Jordan “Moh’d Sami” Ashhab

12. Simulink Summer 2008 University of Jordan “Moh’d Sami” Ashhab

12. Simulink Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Simulink Matlab Interaction Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Matlab Course Projects Electromagnetic Levitation Spring-Mass-Damper Stock Market Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Electromagnetic Levitation Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Spring-Mass-Damper Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Stock Market Summer 2008 University of Jordan “Moh’d Sami” Ashhab

Stock Market Summer 2008 University of Jordan “Moh’d Sami” Ashhab

MATLAB Thank You Summer 2008 University of Jordan “Moh’d Sami” Ashhab
- Slides: 36