You are on page 1of 37

ChE 208

Lecture # 4_1
MATLAB Basics

Dr. Nahid Sanzida


nahidsanzida@che.buet.ac.bd
Objectives
• OBJECTIVES
At the completion of this module, the student
should be able to:
· Understand the MATLAB workspace.
· Perform basic operations.
· Use common mathematical functions.
· Create and manage script M-files.
· Perform array operations.
Prerequisite Mathematical Skills: Mathematics.
Prerequisite Engineering and Science Skills:
PC Windows operations
What is MATLAB?
A software environment for interactive numerical
computations: specifically designed with engineering
applications in mind
• Ideal for rapid development
• Examples:
-Matrix computations and linear algebra
-Solving nonlinear equations
-Numerical solution of ordinary/partial differential equations
-Mathematical optimisation
-Statistics and data analysis
-Signal processing
-Modelling of dynamical systems
-Simulation of engineering systems
MATLAB is a powerful, general-purpose system or
environment for doing mathematics, scientific and
engineering calculations.
Why should you learn MATLAB?
MATLAB used (on a daily basis) in many engineering
companies: 1 million users worldwide
MATLAB Background
MATLAB = MATrix LABoratory
• Originally a user interface for numerical linear
algebra routines (Lapak/Linpak)

• Commercialized 1984 by The Mathworks


more information on MATLAB, contact

The Mathworks, Inc.


www.mathworks.com
Introductory video
http://www.mathworks.co.uk/videos/matlab
overview-61923.html: MATLAB Overview
MATLAB Introduction

• MATLAB is available for MS Windows,


Macintosh personal computer, Unix and
other operating systems.
• MATLAB is a "High-Performance Numeric
Computation and Visualization Software"
package.
• MATLAB is an interactive system whose
basic data is a matrix that does not require
dimensioning.
MATLAB Introduction
MATLAB supports many types of graph and surface
plots:
• line plots (x vs. y),
• filled plots,
• bar charts,
• pie charts,
• parametric plots,
• polar plots,
• contour plots,
• density plots,
• log axis plots,
• surface plots,
• parametric plots in 3 dimensions and spherical
plots.
MATLAB Introduction
• MATLAB has a number of add-on software modules,
called toolbox, that perform more specialized
computations.
Signal & Image Processing
Signal Processing- Image Processing
Communications - System Identification -
Wavelet Filter Design
Control Design
Control System - Fuzzy Logic - Robust Control - µ-
Analysis and Synthesis - LMI Control - Model
Predictive Control Model-Based Calibration

More than 60 toolboxes!


MATLAB Introduction
• In Windows
systems
MATLAB is
started by
double-clicking
the mouse on
the appropriate
icon.
MATLAB
Command
Window
File
Edit
View
View
View
Web
Help
MATLAB Screen
• Command Window
– type commands

• Current Directory
– View folders and m-files

• Workspace
– View program variables
– Double click on a variable
to see it in the Array Editor

• Command History
– view past commands
– save a whole session
using diary
MATLAB User Environment

Workspace/Variable
Inspector

Command Window

Command History
Data Types
Data Types Characteristics

Integer Whole numbers stored exactly

Real Numbers, which may have fractional


parts, with limited precision

Double Similar to real but with greater precision


Precision

Complex Complex numbers: stored as an


ordered pair of real numbers

Logical A Boolean value; either true or false

Character A string of characters of fixed length


1. VARIABLES
• Everything (almost) is treated as a double-
precision floating point array by default- Typed
variables (integer, float, char,…) are supported, but usually
used only for specific applications. Not all operations are
supported for all typed variables.
• No need for types. i.e.,

int a;
double b;
float c;
• All variables are created with double precision unless
specified and they are matrices.
Example:
>>x=5; • After these statements, the variables
>>x1=2; are 1x1 matrices with double precision
2. Functions
MATLAB includes hundreds
of functions for:
• Data analysis and visualization,
• Numeric and symbolic computation,
• Engineering and Scientific graphics,
• Modeling, simulation, and prototyping,
• Eigenvalue, singular value
3. Vectors and Matrices
MATLAB works with scalars,
vectors and matrices:
• Basic matrix operations,
• Inverses of matrices,
• Graphs of matrices,
• Matrix manipulation,
• Programming, application
development, and GUI design
4. Graphics
MATLAB has remarkable
graphics capacities:
• 2-D and 3-D plots,
• Line plotting,
• 3-D surface plot,
• Splash screen plot,
• Plot of complex functions and ...
MATLAB Demos
• Demonstrations are
invaluable since they
give an indication of
the MATLAB
capabilities.
• A comprehensive set
are available by
typing the command
>>demo in MATLAB
prompt.
MATLAB Demos
MATLAB has remarkable graphics
capacities, 3_D plots are some of
them:
• 3-D plots in Handel Graphics
• Plot Type,
• Shading,
• Colormap,
• Axis and ...
MATLAB Demos
MATLAB has many toolboxes:
• Control toolbox is one of the
important toolbox in MATLAB.
• RLC Circuit Response,
• Gain and Phase Margins,
• Notch Filter Discrete,
• PID and ...
MATLAB Demos
MATLAB has many toolboxes:
• Signal Processing toolbox is one of
the important toolobx in MATLAB.
• Designing Filter,
• Filtering a Signal,
• Discrete and Continuous Fourier
Transform,
• Spectral Analysis and ...
MATLAB Demos
• Simulink has the ability to simulate a large range
of systems, from very simple to extraordinarily
complex. The Model and demonstrations that you
will see in this section include both simple and
complex systems.
Simulink has the ability to simulate a large range of
systems, in the menu of Simulation we have:
• Pause
• Stop
• Simulation Parameters
• Start

You might also like