Matlab Programming for Engineers - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Matlab Programming for Engineers

Description:

Matlab Programming for Engineers Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data Types Input/Output Functions – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 22
Provided by: vma4
Category:

less

Transcript and Presenter's Notes

Title: Matlab Programming for Engineers


1
Matlab Programming for Engineers
Introduction to Matlab Matlab Basics
Branching Statements Loops User Defined
Functions Additional Data Types Input/Output
Functions Simulink Toolbox Important
Toolboxes (if time is available)
Dr. Nidal Farhat
2
Objectives
  • The Advantages of Matlab
  • Disadvantages of Matlab
  • The Matlab Environment
  • Using Matlab as a scratch Pad

3
Advantages and Disadvantages of Matlab
  • Matlab MATrix LABoratory
  • Advantages
  • Ease of Use
  • Platform Independent (All versions of Windows,
    Linux, Unix, Mac.)
  • Predefined Functions and Toolboxes
  • Device-Independent Plotting
  • Graphical User Interface
  • Matlab compiler
  • Disadvantages
  • Interpreted programming language, slower than
    C and V. Fortran.

4
The Matlab Environment
Matlab Command Window User input area Also
results appear in this window
Current directory browser
Command history
5
The Matlab Environment
6
The Matlab Environment
Script files / M-files
7
The Matlab Environment
  • The Edit/Debug Window

8
The Matlab Environment
9
The Matlab Environment (Figure Windows)
10
The Matlab Environment (Figure Windows)
11
The Matlab Environment (Workspace)
  • whos
  • Display the value of any variable in the WS
  • clear var1 var2
  • Double-click any var in the WS browser

12
The Matlab Environment (Workspace)
13
The Matlab Environment (Getting Help)
14
The Matlab Environment (Getting Help)
15
The Matlab Environment (Getting Help)
lookfor Search the quick summery information in
each file
16
The Matlab Environment (Getting Help)
help Search function name
17
The Matlab Environment (Getting Help)
18
The Matlab Environment
  • A few important commands
  • clc clears command window
  • clf clears current figure
  • clear clear variables in the WS
  • Ctrlc aborts the execution of the program
  • exit exits Matlab
  • !(command) runs the command in the operating
    system (ex. dir, copy )
  • save/load (WS) saves and loads the WS

19
The Matlab Search Path
  • If a command (name) is executed Matlab seeks for
  • A variable with the same name in the current WS.
  • M-file in the same directory
  • M-file in the any directory in the search path

Sequence is important
20
MATLAB Math Assignment Operators 
  • Power () or (.)  ab or   a.b
  • Multiplication () or (.)  ab  or  a.b
  • Division (/)  or  (./)  a/b  or  a./b   
  • or  (\)  or (.\)  b\a  or  b.\a
  • NOTE         56/8 8\56
  • Addition ()      a b
  • Subtraction  (-)        a b
  • Assignment  ()    a b     (assign b to a)

21
HW1
  • The distance traveled by a ball falling in the
    air is given by the equation
  • Use the Matlab to plot the path of the ball (y)
    as a function of time from t0s to t5s, if
Write a Comment
User Comments (0)
About PowerShow.com