Title: Introduction to MATLAB
1Introduction to MATLAB
- Chris Diduch
- University of New Brunswick
- January 31 February 4, 2004
- Royal Bhutan University
- RBIT, Rinchending
- Day-1
2Who is your instructor?
Chris Diduch Professor Electrical and Computer
Engineering University of New Brunswick Fredericto
n, Canada, E3B 5A3 diduch_at_unb.ca
3Research Interests
- Control systems,
- Computer control systems
- Failure detection and isolation
- Embedded and real time systems
- Applications control of electric drives,
- robotics, injection molding machines,
- distributed power systems.
4Courses
- Electricity and magnetism, circuits, systems
dynamics, microprocessors, embedded systems and
digital interfacing, robotics, real time systems,
VLSI design - Advanced control systems, computer control
systems
5What is MATLAB?
- MATrix LABoratory
- Originated as a vehicle for teaching and applying
linear algebra and numerical methods. - Rapid analysis, design and prototyping.
- Arrays are the basic data type.
- Built-in functions are optimized for vector
operations. - zxy z
- for i15
- zzxiyi
- end
6MATLAB
Programming Language
Built-in Functions
User-written Functions
Graphics 2D 3D Color Lighting Animation
External Files Fortran and C
Computation Linear Algebra Data Analysis Sig
Process Polynomials Integration ODE's
MATLAB Toolboxes Signal Processing Neural
Networks Communications Image Processing
3rd Party Toolboxes Robotics Robot Vision
Physical IO Analog Digital
Simulink Stateflow RT Workshop Data
Acquisition xPC Target
7Features of MATLAB
- The MATLAB programming language
- Built-in MATLAB functions
- Graphics
- Linear algebra
- Data analysis
- Signal processing
- Polynomials and interpolation
- Numerically solving differential equations
- External interfaces C, Fortran
8The Student Edition of MATLAB
- MATLAB Toolboxes
- Simulink
- Signal Processing Toolbox\
- Symbolic Math Toolbox
- Where Do I Get MATLAB? On-line Help?
- www.mathworks.com
9MATLAB Windows
- Launchpad Window (I call it the MATLAB window)
- Command Window
- Workspace Window
- Command History Window
- Current Directory Window
- Edit Window
- Graphics Window
10Help and Assistance
- command lookfor
- command help
- command helpwin
- command helpdesk
- command demo
11MATLAB Data Types
- Basic type is the array
- Dimensioning is automatic
- Data objects
- integers
- double
- matrices
- character (or text) strings
- structures
- cells
12Display and Formatting
- MATLAB is case sensitive
- A semi-colon at the end of a line suppresses
screen output - To display one page at a time type more on
- Display formats
- short
- long
- e, g, hex
- rat, bank
13MATLAB File Types
- M-files scripts and functions are saved as text
files with a .m extension - Mat-files workspace variables are saves as
binary files with a .mat extension. - Mex-files MATLAB callable Fortran and C programs
with a .mex extension. - Fig-files the saved form of a figure window.
14Where do we use MATLAB?
- Linear Algebra MATH 1503
- Simulation Analysis CMPE 2013
- Systems and Control EE 3313, EE 3323
- Signals EE 3513, Industrial Control EE 4343
- Robotics EE 4353
- Power Systems EE 4411
- Algorithms in Real Time CMPE 4543
- Research and Graduate courses
15On-line Help
- help FunctionName or ScriptName
- help help
- lookfor Name
- demo
- helpwin
- helpdesk
16Overview
- MATLAB windows and basic operations
- Programming in MATLAB
- Analysis
- Graphics
- Toolboxes
17On-line Course Material
- The workbook and all of the program examples are
available on-line at - http//www.ece.unb.ca/Courses/Matlab/CD
18Element-by-Element Operations
- Use dot operation for element-by-element
operations - . ./ .
- A a1 a2 a3
- B b1 b2 b3
- C A .op B says
- C a1 op b1, a2 op b2, a3 op b3
19Syntax
20Matrices
Column
Row
21Trajectory of a Projectile
y
v0
x
?
v(t)
H
22MATLAB Path and PWD
- PWD present working directory
- Default is /matlab/path
- The MATLAB path
- All MATLAB directories are included in the search
path. - You may add paths to your directories
23For First Time Users
- Issues
- Not being in the right directory
- Not saving files in the right directory
- Not updating an existing function or script file
while editing. - Default working directory is /MATLAB/WORK