0% found this document useful (0 votes)
130 views

Matlab: The Language of Technical Computing

This document provides a summary of MATLAB commands and functions organized into the following sections: Getting Started, which describes basic commands like help, dir, and format; Generating Matrices, which discusses commands to create matrices filled with zeros, ones, random numbers, etc.; Manipulating Matrices, including operations like determinant, eigenvalues, and finding elements; Flow Control, covering conditional statements, loops, and other programming constructs; Scripts and Functions; Using MATLAB Graphics, which outlines commands for 2D and 3D plotting including plot, mesh, lighting controls, and viewpoint manipulation; and Specialized. The document serves as a user guide to the essential MATLAB language elements and graphics capabilities.

Uploaded by

rauk83
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

Matlab: The Language of Technical Computing

This document provides a summary of MATLAB commands and functions organized into the following sections: Getting Started, which describes basic commands like help, dir, and format; Generating Matrices, which discusses commands to create matrices filled with zeros, ones, random numbers, etc.; Manipulating Matrices, including operations like determinant, eigenvalues, and finding elements; Flow Control, covering conditional statements, loops, and other programming constructs; Scripts and Functions; Using MATLAB Graphics, which outlines commands for 2D and 3D plotting including plot, mesh, lighting controls, and viewpoint manipulation; and Specialized. The document serves as a user guide to the essential MATLAB language elements and graphics capabilities.

Uploaded by

rauk83
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

MATLAB

The Language of Technical Computing

User Guide

Chapter 1 Getting Started


MATLAB help
help topic
lookfor topic
helpwin topic

search for a topic helpfile


search topic in helpfiles
use help window on a particular topic
disk file manipulation
displays all files
shows the content of a file
delete file
change directory

dir
type
delete
cd
diary command
diary
diary filename
diary off

creates a diary of the MATLAB session


save the session in a file
stop recording the session
operators

+
*
/
\
^

()

addition
subtraction
multiplication
division
left division
power
complex conjugate transpose
specify evaluation odder
long command lines, with followed by Return
constants

pi
i
j
eps
realmin
realmax
inf
NaN

3,14159265
imaginary unit
same as i
floating-point relative precision , 2-52
smallest floating-point number, 2-1022
largest floating-point number, (2-)21023
infinity
not-a-number
format command

format short
format short e

4/3 1.3333 ; 1.2345e-6 0


4/3 1.3333e000 ; 1.2345e-6 1.2345e-006

4/3 1.3333 ; 1.2345e-6 1.2345e-006


4/3 1.3333333333; 1.2345e-6 0.00000123450
4/3 1.3333333e+000; 1.2345e-6 1.234500e-006
4/3 1.333333333333 ; 1.2345e-6 1.2345e-006
4/3 1.33 ; 1.2345e-6 0.00
4/3 4/3 ; 1.2345e-6 1/810045
4/3 3ff555555555 ; 1.2345e-6 3eb4b623fabfd2
suppresses many of the blank lines

format short g
format long
format long e
format long g
format bank
format rat
format hex
format compact

command line editing


recall previous line
recall next line
move back one character
move forward one character
move right one word
move left one word
move to beginning of line
move to end of line
clear line
delete character at cursor
delete character before cursor

or ctrl-p
or ctrl-n
or ctrl-b
or ctrl-f
ctrl- or ctrl-r
ctrl- or ctrl-l
home or ctrl-a
end or ctrl-e
esc or ctrl-u
del or ctrl-d
backspace or ctrl-h

generating matrices
zeros( )
ones( )
rand( )
randn( )
load *.dat
magic(n)
[n11 n12 n13;n21 n22 23;n31 n32 n33]

all elements are zeros


all elements are ones
uniformly distributed random elements
normally distributed random elements
load matrix from a file
generates a n-by-n magic square
generates a 3-by-3 matrix

manipulating matrices
[]
det( )
eig( )
poly( )
sum( )
.*
./
.\
.^
.
find( )

delete matrix arrays


determinant of a matrix
eigenvalues of a matrix
coefficients of the characteristic polynomial
sum of each column
element-by-element multiplication
element-by-element division
element-by-element left multiplication
element-by-element power
unconjugated array transpose
determines the indices of elements by given condition
flow control

==
<
>
isequal
isemty
all
any
if else if else end
switch case otherwise end
for end
while end
break
{ } or cell
text
double( )
char( )
cellstr( )
S.
S.field designator

equal
less
greater
check matrices with not the same size for equality
check if matrices are emty
check all if they are true
check any if it is true
syntax of the if statement
executes statements based on value of a variable
repeats statements a fixed number of times
repeats statements an indefinite number of times
exit earlier from a for or a while loop
cell array
enter text into MATLAB using single quotes
converts text to ASCII codes for each character
converts ASCII codes or cell array into text
convert text into cell array of strings
structures are multidimensional MATLAB arrays
create array with element by textual field designator

scripts and functions


.m
M-File as a script
M-File as a function
function y = f(x)
global x
eval( )
fmins( ,x)
fmax( ,x)
fzero( ,x)

M-File, executable script


MATLAB executes commands found in the file
can accept input arguments and can return outputs
first line of a function M-File starts with function
declare a variable as global in all functions
evaluate expression or execute command in text string
finds minimum, x = rough guess of the location
finds maximum, x = rough guess of the location
finds zeros, x = rough guess of the location

Chapter 2 Using MATLAB Graphics


2.1 Building 2-D Graphs
window handle
creates a new window
divide screen in n rows m columns print in i window

figure
subplot(n,m,i)

functions that produce basic line plots


line ([x1 y1 z1],[x2 y2 z2],color,r)
plot( )
loglog( )
semilogx( )
semilogy( )
plotyy( )

draws a red line from P(x1,y1,z2) to P(x2,y2,z2)


Graph with linear scales for both axes
Graph with logarithmic scales for both axes
Graph with logarithmic scales only for x axes
Graph with logarithmic scales only for y axes
Graph with y-tick labels on the left and right side
multiple plots

plot(t,y1,t,y2)
hold on/off
ishold

2 functions in one plot (t = x ,y1 y2 = y )


plots all functions after hold on in one plot
test the current hold state
colors line styles markers
plot(x,y,color_line style_marker)

Symbol

color (RGB)

c
m
y
r
g
b
w
k

cyan (0 1 1)
magenta (1 0 1)
yellow (1 1 0)
red (1 0 0)
green (0 1 0)
blue (0 0 1)
white (1 1 1)
black (0 0 0) (default)

Symbol

line style

-:
-.
none

solid line (default)


dashed line
dotted line
dash-dot line
no line

Symbol

marker

+
o
*
.
x
square
diamond
^
v
>
<
pentagram
hexagram
none

plus sign
circle
asterisk
point
cross
square
diamond
upward pointing triangle
downward pointing triangle
right pointing triangle
left pointing triangle
five-pointed star
six-pointed star
no marker (default)
axis handle

axis on/off
axis vis3d on/off
axis ([xmin,xmax,ymin,ymax,zmin,zmax])
axis square
axis equal
axis tight
axis auto
axis manual
axis ij
axis xy
axis image
axis normal
DataAspectRatio
DataAspectRatioMode
PlotBoxAspectRatio
PlotBoxAspectRatioMode
Position [left,bottom,width,height]
XLim, YLim, ZLim
XLimMode, YLimMode, ZLimMode

axis are visible/hidden


enable rotation of 3-D objects
axis range
x-y-axis equal in length
x-y-axis equal in units
axis conform to plotted data
axis scaling to default
freezes scaling at current limits
matrix axes mode
default Cartesian axes mode
aspect radio of axes the same as the image
restore current axis box, remove any restrictions
relative scaling of the axis data value
in auto axis scale the highest resolution in space
proportions of the axis plot box
in auto the value is [1 1 1]
location and size of axis (left, bottom = offset)
minimum and maximum limits of the axes
in auto MATLAB selects the axis limits

text and text values


title(text)
xlabel(text)
ylabel(text)
zlabel(text)
legend
text(x,y,text,Horizontal, ,Vertikal, )
HorizontalAlignment left | center | right
VerticalAlignment middle | top | bottom

adds title to the graph


adds a label to the x-axis
adds a label to the y-axis
adds a label to the z-axis
adds a legend to an existing graph
text at a specified (x,y) location
horizontal placement of the text
verical placement of the text

text(x,y,text1,text2,text3)
gtext

multiline text at a specified (x,y) location


places text using the mouse

special text strings (TeX characters)


text in italic
Greek letters ( | | )
|

change font to times

\it
\alpha | beta | delta
\leftarrow | rightarrow
\pi
\bullet
\fontname{times}

2.2 Building 3-D Graphs


functions that produce 3-D plots
plot3(x,y,z)
mesh(x,y,z,c),surf(x,y,z,c)
meshc,surfc
meshz
pcolor
surfl
surface

3D-plot,x-y-z are vectors of same length


Surface plot with colormap c
Surface plot with contour plot beneath it
Surface plot with curtain plot
Flat surface plot (value is proportional to color)
Surface plot illuminated from specified direction
Low-level function
plot handle

grid on/off
hidden on/off
colorbar
box on/off
rotate3d

turns grid to visible/hidden


disable hidden line removal
strip of color corresponding to colormap
turns 3-D box to visible/hidden
mouse-based 3-D rotation of the view
colormap
red colors
bluecolors
colors spring
colors summer
colors autumn
colors winter
gray colors

hot
cool
spring
summer
autumn
winter
gray
lighting
color
style local/infinite
position
visible
AmbientLightColor

color of the light


point source (local) or light placed in infinity
position of the light
light is visible (default is hidden)
specified the color of the background

intensity the ambient component is reflected


intensity the diffuse component is reflected
intensity the specular component is reflected
size of specular highlight
degree which reflected light is colored the object
method to calculate effect of light on the faces
method to calculate effect of light on the edges
how faces lit when vertex points away from camera
color of object faces
color of object edges
contain normal vectors for each vertex of the object
vertex normals set to auto

AmbientStrength
DiffuseStrength
SpecularStrength
SpecularExponent
SpecularColorReflectance
FaceLighting flat/Gouraud/Phong
EdgeLighting flat/Gouraud/Phong
BackFaceLighting reverselit/lit
FaceColor
EdgeColor
VertexNormals
NormalMode

material
makes the objects shiny
makes the objects dull
makes the objects metallic

material shiny
material dutty
material metal

viewpoint control
set viewpoint

view([Azimuth Elevation])

camera properties
CameraPosition
CameraPositionMode auto/manual
CameraTarget
CameraTargetMode auto/manual
CameraUpVector
CameraUpVectorMode auto/manual
CameraViewAngle
CameraViewAngleModeauto/manual
orthographic/perspective Projection

location of the viewpoint in axis units


position based on scene/ user specified
location in the axes that the camera points to
center of axes plot box/ user specified
rotation of camera around viewing axis
y-axis in 2D, z-axis in 3D/ user specified
specifies the view of the lence
smallest angle that captures the scene/user specified
orthographic or perspective projection

projection types and camera location


Z-buffer / orthographic
painters / orthographic
Z-buffer / perspective
painters / perspective

CameraViewAngle = scene at Cameratarget


all objects display regardless of CameraPosition
CameraViewAngle = from Cameraposition to infinity
not recommended if objects behind CameraPosition

2.3 Specialized Graphs


bar( )
barh( )
bar3( )
bar3h( )
bar(Y,detach)
bar(Y,group)
bar(Y,stack)
bar(x,y)
area( )
area(x,y)
pie( )
pie3
pie(x,value)
hist( )
rose(x)
stem( )
stem3( )

2-D vertical bar graph


2-D horizontal bar graph
3-D vertical bar graph
3-D horizontal bar graph
detached bars = default
grouped bars
each bar equals the sum of the elements
bar with y vector for height and vector of x values
plots the value in each column of a matrix
plots y vector values with x axes values
2D-plot of the percentage of elements in a matrix
3D-plot of the percentage of elements in a matrix
value = offset a slice of a pie
shows the distribution of elements in Y
histogram in polar coordinate system(x = x*pi/180)
plots a 2-D discrete data graph
plots a 3-D discrete data graph

t = sampling rate, y = values, filled marker symbols


stairstep plot

stem(t,y,fill)
stairs( )

direction and velocity vector graphs


compass
feather
quiver
quiver3

vectors emanating from the origin of a polar plot


vectors equally spaced points along horizontal line
displays 2-D vectors specified by (u,v) components
displays 3-D vectors specified by (u,v,w) components
contour plots

clabel
contour
contour3
contourf

generates labels using contour matrix


2-D isolines generated from values given by matrix Z
3-D isolines generated from values given by matrix Z
2-D contour plot, fills area between lines with a color
animation
initialize memory for a matrix
generate each movie frame
run the movie

moviein
getframe
movie
erase modes
EraseMode none
EraseMode background
EraseMode xor

MATLAB does not erase objects when it is moved


MATLAB erases objects by redrawing in background
MATLAB erases only the object, used for animations

2.4 Images
image
imagesc
imread
imwrite
imfinfo
axis
image(X); colormap(map)
imagesc(I,[0 1]); colormap( )
image(RGB)
drawnow

display image (create image object)


scale data and display as image
read image from graphics file
write image to graphics file
get image information from graphics file
plot axis scaling and appearance from image
display mode Indexed uses colormap colors
display mode Intensity uses colormap colors
display mode Truecolor do not use colormap
update the display with each pass through a loop

2.5 3-D Modeling


polygon with one face and color

patch(x,y,[z],colordata)
colordata

single per face or per vertex colors of x,y and z data


color data is scaled or used directly as indices
single per face or per vertex colors of faces/vertices
can be invisible,single color,flat color or interpolated
can be invisible,single color,flat color or interpolated
color of the marker or the edgecolor for filled marker
fill color for markers that are closed shapes

CData
CDataMapping
FaceVertexCData
EdgeColor
FaceColor
MarkerEdgeColor
MarkerFaceColor

2.6 Printing MATLAB Graphics


print
print devicename options filename
printopt.m
set(gcf,PaperPosition,[Position])
set(gcf,PaperPositionMode,auto)
set(gcf,PaperOrientation,landscape)
set(gcf,PaperType,a5)

prints resulting figure to default printer


prints figure with options to device printer and file
setting file for print values
Position= left right width heigth
width and height determined by figures dimensions
paperorientation set to landscape (default = portrait)
sets paper size to a5

specifying fonts and character sets


FontName
FontSize
FontUnits
FontWeigth
FontAngle

Courier,Symbol,Times-Roman,Helvetica
4..35
points
bold
oblique

2.7 Handle Graphics


properties common to all objects
ButtonDownFcn
ChangeFcn
Children
Clipping
CreateFcn
DeleteFcn
BusyAction
Interruptible
CloseRequestFcn
Parent
Selected

callback routine executed when button press occurs


callback routine executed when a property changes
handles all this objects children objects
enables or disables clipping
callback routine executed when object is created
callback routine executed when object is deleted
controls how to handle callback routine interrupts
determines a callback routine can be interrupted
callback routine by close figure or end session
the objects parent
indicates whether object is selected

whether the visually indicates the selection state


User-specified object label
the type of object (figure,line,text)
any data you want to associate with the object
determines whether or not the object is visible

SelectionHighlight
Tag
Type
UserData
Visible

graphics object creation functions


axes
figure
image
light
line
patch
surface
text
uicontrol
uimenus
handle=function(propertyname,value)
set/get(gcf, )
set/get(gca, )
set/get(gco, )
set/get(0, )
findobj(propertyname,value)
delete( )

rectangular coordinate system


windows for displayed graphics
2-D picture
light source
line formed by connecting coordinate data
polygonal shell
created with rectangular faces
character string
programmable user-interface device
programmable menu
object creation function syntax
value of the root CurrentFigure property
value of the current Figure CurrentAxes property
value of the current Figure CurrentObject property
specifying default values
searching for objects by property value
delete objects (gca, figure,)

controlling graphics output


nextplot add (= default)
nextplot replacechildren (= clf,cla)
nextplot replace (= clf reset, cla reset)
newplot
HandleVisibility
HandleVisibility on
HandleVisibility callback
HandleVisibility off
ShownHiddenHandles off(default)/on
close(hidden)
close(all,hidden)

new object without clearing figure and axes


remove child objects, do not reset figure or axis
remove all child objects and reset figure and axis
checks current figures and axes NextPlot property
allow to control availability of the objects handle
objects handle is available to any function
handle is hidden from functions on command line
handle is hidden from callback and command line
disables or enables handle visibility control
close nonvisible figures
closes all figures

2.8 Figures
figures properties
Menubar

Name NumberTitle Resize


Visible WindowStyle
Children Parent Position Tag Type
Units Userdata Color
Colormap Dithermap DithermapMode
Fixedcolors MinColorMap ShareColors
BackingStore Renderer
CurrentAxes CurrentCharacter CurrentMenu
CurrentObject CurrentPoint SelectionType
ButtonDownFcn ChangeFcn CloseRequestFcn
DeleteFcn KeyPressFcn ResizeFcn
BusyAction Interruptible WindowButtonUpFcn
WindowButtonDownFcn
Pointer PointerShapeCData PointerShapeHotSpot
IntergeHandle HandleVisibility NextPlot
InvertHardcopy PaperOrientation PaperPosition
PaperPositionMode PaperSize PaperType
PaperUnits

Style and appearance


General information
Colormap
Rendering graphics objects
Current selections
Callback routine execution
Pointer definition
Figure handles
Printing
set/get(gcf, )

value of the root CurrentFigure property

Position[left bottom width height]


Units [inches|centimetres|points|pixels]
screensize

set the position of a figure


define units of values (pixels = default)
obtain the information about the screensize

controlling color
Colormap
FixedColors
MinColormap
ShareColors on/off
Dithermap
DithermapMode auto/manual

the figure colormap, n-by-3 array of RGB values


specified color used by figure that not in colormap
minimum number of system color table slots
MATLAB shares colors with other colormaps
predefined colormap for displaying true color
wether MATLAB use current map or creat new one
rendering options

BackingStore on/off
Renderer

faster redrawing when obscured figure windows


faster rendering of graphic objects
pointers

Pointer custom
PointerShapeCData
PointerShapeHotSpot

displays pointer you define


matrix to specify the pointer
1s = black | 2s = white | Nans = transparent
pixel that indicates pointer location

printing figures
PaperOrientation
PaperPosition
PaperPositionMode
Papersize
Papertype
PaperUnits
InvertHardCopy

horizontal or vertical paper orientation


location and size of figure on printed page
paperposition or actual size printed figure
size of papertype
standard paper sizes
units used by paperposition and papersize
invert black background and white lines

2.9 Axes
axes properties

Style and appearance

General information

Annotation

Axis control

Viewpoint

Scaling and aspect ratio


Callback execution
Rendering Method
Targeting Axes
Color
set/get(gca, )

Box Clipping GridLineStyle Layer


LineStyleOrder LineWidth MinorGridLineStyle
SelectionHighlight TickDir TickDirMode
Ticklength Visible
Children ClippingMode CurrentPoint
Parent Position Selected Tag Type
Units UserData
FontAngle FontName FontSize
FontUnits FontWeight Title
XLabel YLabel ZLabel
XTickLabel YTickLabel ZTickLabel
XDir YDir ZDir
XGrid YGrid Z Grid
XLim YLim ZLim
XScale YScale
ZScale
XTick YTick ZTick
XAxisLocation YAxisLocation
CameraPosition
CameraPositionMode
CameraTarget CameraTargetMode
CameraUpVector CameraUpVectorMode
CameraAngleView CameraAngleViewMode
View
DataAspectRatio DataAspectRatioMode
PlotBoxAspectRatio PlotBoxAspectRatioMode
ProjectionType
BusyAction ButtonDownFcn CreateFcn
DeleteFcn Interruptible
DrawMode
HandleVisibility NextPlot
AmbientLightColor CLim CLimMode
Color ColorOrder XColor
YColor ZColor
value of the current Figure CurrentAxes property

individual axis control


XLim, YLim, ZLim
XLimMode, YLimMode, ZLimMode
XTick, YTick, ZTick
XTickMode, YTickMode, ZTickMode
XTickLabel, YTickLabel, ZTickLabel
XTickLabelMode, YTickLabelMode,
ZTickLabelMode
XDir, YDir, ZDir
XDir, YDir, ZDir reverse
TickDirMode
XAxisLocation top | bottom
YAxisLocation left | right

sets the axis range


axis limits automatically by MATLAB or manually
location of the tick marks along the axis
tick mark automatically by MATLAB or manually
specifies the labels for the axis tick marks
tick mark labels automatically by MATLAB or
manually
set the direction of increasing axis values
produces a plot axis decreases from left to right
direction of axis tick marks
location of the x-axis
location of the y-axis

colors controlled by axes


Color
XColor, YColor, ZColor
CLim
CLimMode
ColorOrder
LinestyleOrder

axes background color


color of axis lines tick markers, gridlines, labels
mapping of data values to colors
automatic or manual of CLim property
Line color autocycle order
line styles autocycle order

Chapter 3 - Building GUIs (Graphic User Interface)


propedit( )
guide
Property Inspector --> String Property
Property Inspector --> Callback
align
controlled figure
menue
object browser

invoke the property inspector


opens the guide control panel
name of the object (buttons, boxes)
define callback routines
tool to interactively align uicontrols and axes
figure put into an editable state
tool to implement an uimenu
tool to select objects interactively

The Big Picture


The user interface you create is a
single entity with a
certain personality to help a
specific user perform a

specific task.
It is very important that:
1. The user always know where they are.
2. They do always know where to go next.
!!! The GUI has to be simple, consistent and familiar !!!
simple
consistent
familiar

unity clarity directness elegance


harmony integrity alignment
comfort charm friendliness

Simplicity:

emphasize form, not numbers visualisation is more qualitative than numbers


minimize the area of interaction dont use two figures if one will do
use graphical input rather than numerical let the user enter data directly
touching the graphic

Consistency:

keep it well structured


keep the user free from feeling disorientated and confused is very important

Familiarity:

use the familiar to draw users into the GUI a small connection to the users
real world experience (touch-tone phone pad)
The Dynamic Interface
snappy direct
smooth physical
friendly encouraging

immediate
continuous
reversible

Permit Direct Manipulation whenever possible, let the user grab the data (i.e. slider)

3.1 Design Process

Define Task

Start

Draw GUI

Test Design

Design

Write Code

Test Code

Stop

Implementation

Dont start coding until youve done designing


Start with the ideal dont make compromises to soon
Test the GUI on paper

3.2 GUI Implementation


writing callbacks

Function callbacks are faster write complete callbacks as a function


Switchyard programming prevents function proliferation - send all callbacks
to a single function with a switch statement
Use gcbo and gcbf for self-referential callbacks if the callback needs to know
about or modify its own state the functions gcbo and gcbf are short
Stateless programming with findobj with findobj you can locate an object
whenever you need to modify
Avoid potential errors by disabling uicontroles if a callback is likely to cause
an error, set the Enable property on the calling object to off
Use subfunctions inside the switchyard callback

Dont forget about the ButtoDownFcn everything from a line to a figure has
a ButtoDownFcn
Prevent overplotting with handle visibility the HandleVisibility property lets
your hide your GUI from the MATLAB command line
Animate with WindowButtonMotionFcn animate a response as the mouse is
being dragged in combination with WindowButtonDownFcn or
WindowButtonUpFcn

Chapter 4 - Control System Toolbox


4.1 Linear Time-Invariant (LTI) Models
transfer function with sampling time Ts (z1)
numerator(s) (cell array of row vectors)
denominator(s) (cell array of row vectors)
string s,z,p,q,z-1
zero/pole/gain with sampling time Ts
gains (two-dimensional matrix)
poles (cell array of column vectors)
zeros (cell array of column vectors)
string s,z,p,q,z-1
state space with sampling time Ts
state matrix A (two-dimensional matrix)
input-to-state matrix B (two-dimensional matrix)
state-to-outp. matrix C (two-dimensional matrix)
feedthrough matrix D (two-dimensional matrix)
descriptor E matrix (two-dimensional matrix)
state names (cell vector of strings)
retrieve the tf system data stored in LTI object
retrieve the zpk system data stored in LTI object
retrieve the ss system data stored in LTI object
sample time, continuous time, time unspecified
create descriptor state-space model
create discrete filter with DSP convention (z-1)
list and set all LTI properties and their values
display current properties of the system

tf(num,den,variable,Ts)
num
den
variable
zpk(z,p,k,variable,Ts)
k
p
z
variable
ss(a,b,c,d,e,Ts)
a
b
c
d
e
statename
[num,den,Ts]=tfdata( )
[z,p,k,Ts]=zpkdata( )
[a,b,c,d,Ts]=ssdata( ), dssdata
Ts > 0 ,Ts = 0, Ts = -1
dss( )
filt( )
set( )
get( )

model conversion
conversion to TF
conversion to ZPK
conversion to SS
partial fraction expansion
invert LTI system

sys=tf(sys)
sys=zpk(sys)
sys=ss(sys)
residue
inv( )
LTI properties
set(sys,inputname,text)
set(sys,inputname,text)
notes
Td
userdata
PropertyValue=get(sys,PropertyName)
PropertyValue=sys.PropertyName
sys.PropertyName=PropertyValue
covar( ,w)

names the input of sys (cell array of strings)


names the output of sys (cell array of strings)
notes on the model history (text)
input delay(s) (vector)
additional data (arbitrary)
syntax of accessing property values
direct property referencing with get
direct property referencing with set
covariance of response to white noise

pade approximation of input delays

pade( )

continuous/discrete conversion
c2d( ,Ts)
d2c( )
d2d( ,Ts)
c2d( ,Ts,foh)
d2c( ,tustin)

discretization with sample period Ts


equivalent continuous-time model
resampling at the period Ts
use first-order hold
use Tustin approximation
arithmetic operations
connects systems in parallel
connects systems in serial
horizontal concatenation
vertical concatenation
transpose LTI models
pertranspose LTI models

sys= sys1 + sys2


sys= sys1 * sys2
sys= [sys1 , sys2]
sys= [sys1 ; sys2]
sys.
sys

4.2 Model Analysis Tools


model order reduction
balreal
minreal
modred
class
isa
isct
isdt
isempty
isproper
issiso
size

input/output balancing
minimal realization or pole/zero cancellation
state deletion in I/O balanced realization
general characteristics
model type (tf,zpk, or ss
true if LTI model is of specified type
true for continuous-time model
true for discrete-time model
true for empty LTI model
true for proper LTI models
true for SISO models
output/input/state dimensions
model dynamics

covar
damp
dcgain
dsort
esort
norm
pole,eig
pzmap
tzero

covariance of response to white noise


natural frequency and damping of system poles
low-frequency (DC) gain
sort discrete-time poles by magnitude
sort continuous-time poles by real part
norms of LTI systems
system poles
pole/zero map
system transmission zeros

state-space realization
canonical state-space realizations
controllability matrix
controllability staircase form
controllability and observability gramians
observability matrix
oberservability staircase form
state coordinate transformation
diagonal balancing of state-space realization

canon
ctrb
ctrbf
gram
obsv
obsvf
ss2ss
ssbal

time and frequency response


filter
ltiview
gensig
step( ,tfinal)
impulse( )
initial( ,x0)
lsim( ,u,t,x0)

simulation of discrete SISO filter


LTI Viewer for linear response analysis
input signal generator
step response with final time
impulse response
undriven response to initial condition
response to input u

bode( ,{fmin,fmax})
nyquist( )
nichols( )
sigma( )
linspace
logspace
freqresp( )
evalfr
freqresp
margin
ngrid

bode plot with freq. range


Nyquist plot
Nichols plot
singular value plot
vector of evenly spaced frequencies
vector of logarithmically spaced frequencies
complex frequency response
response at single complex frequency
response over frequency grid
gain and phase margin
grid lines for Nichols plot

4.3 The LTI Viewer


ltiblock
ltiview
ltiview(plottype,sys,extras)
plottype
sys
extras

Simulink block for LTI systems


initialize LTI viewer
initialize LTI viewer with input arguments
= time and frequency response
= LTI system
= extras of the time and frequency response
menu options

File --> Import


File --> Export
Edit --> Plot Configurations
Edit --> Refresh Systems
Edit --> Delete Systems

import a LTI system form workspace or file


export a LTI system to workspace or disc file
configuration of displaying responses
the displayed system is refreshed
delete models

Edit --> Line Styles

define the line style of response plot


right mouse button options
change the response plot type
hide or show systems
change plot options

Plot Types
Systems
Characteristics

Specifying a Simulink Model Portion for Analysis

create the Simulink Model


select Tools --> Linear Analysis, a Simulink Toolbox and the LTI
Viewer will open
insert the Input Point and the Output Point from the Toolbox
select Set Operating Point in the Simulink menu on the LTI
Viewer Tool
specify the operating conditions listed in the Operating Point
window

4.4 Control Design Tools


system modeling
append
augstate
connect
conv
drss, drmodel
feedback
ord2
pade
parallel
rss
series
star

group systems by appending inputs and outputs


augment outputs by appending states
block diagram modelling
convolution of two polynomials
generate random discrete state-space model
feedback connection
generate second-order model
pade approximation of time delays
generalized parallel connection
generate random continuous state-space model
generalized series connection
star product (LFT interconnection)
the root locus design GUI

pzmap
rltool
rlocfind
rlocus
sgrid
zgrid

pole-zero map
root locus design GUI
interactive root locus gain selection
evans root locus plot
continuous , grid for root locus
discrete , grid for root locus
pole placement tools

acker
estim

SISO pole placement


form state estimator given estimator gain

MIMO pole placement


form output-feedback compensator

place
reg

equation solvers
care
dare
lyap
dlyap

solve continuous-time algebraic Ricatti equations


solve discrete-time algebraic Ricatti equations
solve continuous-time Lyapunov equations
solve discrete-time Lyapunov equations
LQG design

dlqr
kalman
kalmd
lqgreg
lqr
lqrd
lqry
rltool

LQ-optimal gain for discrete systems


Kalman estimator
discrete Kalman estimator for continuous plant
form LQG regulator with LQgain and Kalman filt.
LQ-optimal gain for continuous system
discrete LQ gain for continuous plant
LQ-optimal gain with output weighting
initialize root locus design GUI

4.5 The Root Locus Design GUI


initialize root locus design GUI with LTI object
rltool(sys)
rltool(sys,comp,LocationFlag,FeedbackSign) initialize root locus design GUI with compensator
compensator in forward loop
LocationFlag = 1
compensator in feedback loop
LocationFlag = 2
negative feedback
FeedbackSign = -1
positive feedback
FeedbackSign = 1
opens an LTI object
File --> Import
move pole
grab pole with with mouse pointer
Displaying system responses
Analysis -->
specifying design constrains
Edit --> Root Locus --> Design Constrains
draws the model in Simulink
Tool --> Drawing Simulink Diagram
saves models to workspace or file
File --> Export

Chapter 5 Using The Nootbook


5.1 Creating an M-Book
1. Open your Microsoft Word and than open file.
2. In the MATLAB-Path select Notebook and the Pc.
3. Open the Word-Document M-Book.doc or
M-Book95.doc if you are using WINDOWS 95.
Defining and Evaluating MATLAB Commands
Type the command as text and leave the cursor at the end of the text.
Select the Evaluate Cell from the Notebook menu or press Ctrl-Enter.
Entering Commands to initialize the Workspace
Type the command as text and leave the cursor at the end of the text.
Select the Define AutoInit Cell from the Notebook menu.
Grouping MATLAB Commands
Highlight the input cells that are make up the group.
Select the Group Cell from the Notebook menu or press Alt-G.
If the selection includes output cells, the Notebook deletes them.
If the selection includes text, the Notebook places the text after the cell group.
If the selection includes a part of an output or an output cell, the input cell will also be
included.
Using Calc Zone
A calc zone is a contiguous block of related text, input cells and output cells that describe
specific operation or problem.
Highlight the cells and text to be included in the calc zone.
Select the Define Calc Zone from the Notebook menu.
To evaluate a calc zone select the Evaluate Calc Zone command or press Alt-Enter.

Converting a Cell to Text


Position the cursor in the cell.
Select the Undefine Cell from the Notebook menu or press Alt-U.
Evaluating the Entire M-Book
Select the Evaluate M-book from the Notebook menu or press Alt-R.
Evaluating MATLAB Commands in a Loop
Highlight the input cells, including any text or output cells located between them.
Select the Evaluate Loop from the Notebook menu or press Alt-L.
The Evaluate Loop dialog box is shown:

You can specify the number of times that you want MATLAB to evaluate the
commands by entering a number in the Stop After field.

You can start processing the command by clicking on the Start button.

You can suspend processing the commands by clicking on the Pause button.

You can change the delay between iterations by clicking on the Faster and
Slower buttons, either before or during the simulation.

You can stop processing the command by clicking on the Stop button.
Working with MATLAB Output

To delete output cells use the Purge Output Cells command or press Alt-P.
If you want to suppress a graphical output from an input cell, place the cursor in the
input cell and select Toggle Graph Output for Cell from the Notebook menu.
Printing an M-Book
When printing an M-Book, cells are printed in its defined color.
Style
Normal
AutoInit
Error
Input
Output

Font
Times New Roman
Courier New
Courier New
Courier New
Courier New

Size
10 points
10 points
10 points
10 points
10 points

Weight
Bold
Bold
Bold

Color
Black
Dark Blue
Red
Dark Green
Blue

Define Notebook Options


Select Notebook Options in the Notebook menu.
You can choose the output numeric format form a list box.
You can deselect the check box Embedded Figures in M-Book to display graphic
output in a separate figure window.
You can select the check box Use 16-Color Figures to print figures with only 16
colors else it will printed with 256 colors.
Overview
Bring MATLAB to Front
Define AutoInit Cell
Define Calc Zone
Define Input Cell
Evaluate Calc Zone
Evaluate Cell
Evaluate Loop
Evaluate M-book
Group Cells
Hide (Show) Cell Markers
Notebook Options
Purge Output Cells
Toggle Graph Output for Cell
Undefine Cells
Ungroup Cells

Bring the command window to the foreground


creates a autoinit cell
creates a calc zone
creates a input cell
evaluate a calc zone
evaluate an input cell or cell group
evaluate input cells repeatedly
evaluate the entire M-book
create a multi line input cell
hire (or show) cell markers
control display of the Notebook output
delete output cells
suppress or allow graph output on a per-input-cell
convert cells to text
convert a cell group to input cells

Chapter 6 Using Stateflow


In MATLAB/Stateflow gibt es am linken Bildschirmrand die 4 Stateflowobjekte:
1.
2.
3.
4.

State Zustnde
History Junction Gedchtnis, Anwendung bei verschiedenen Hierachieebenen
Default Transition mglicher bergang von einem State zu einem anderen
Connective Junction Knotenpunkt um Transitionen zu vebinden

States:
Schlsselwort
State name
entry

during

exit
on event-name

Erklrung
Name des States muss immer eindeutig sein
Diese Aktion wird unmittelbar nach dem
bergang in den State ausgefhrt also mit
dem Event, das den bergang auslst.
Diese Aktion wird mit jedem Event
ausgefhrt das stattfindet, whrend der
Zustand aktiv ist. Die Aktion wird jedoch
nicht durch das Event ausgefhrt, welches
den bergang auslst
Diese Aktion wird beim verlassen des States
ausgefhrt, also mit dem Event, den den
bergang in den nchsten Zustand auslst.
Diese Aktion wird nur ausgefhrt, wenn der
Zustand aktiv ist und das Ereignis
event-name stattfindet.

Transitions:
allgemeiner Syntax: event[condition]{condition_action}/transition_action
Schlsselwort
event
[condition]
{condition_action}
transition_action

Erklrung
eintretendes Ereigniss
Bedingung die erfllt sein muss
Aktion die ausgefhrt werden soll
erst wenn Ziel der Transition erkannt wurde,
wird die transition_action ausgefhrt

You might also like