You are on page 1of 32

for internal use only Automation

Eng./ Essamand
Nabil
Drives

Lecture No.“2”
SIMATIC HMI
MATLAB
The Human
Programming
Machine Interface
Introduction

MATLAB
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis
The Language of Technical
Curve fitting Computing
Symbolic math.

Signal processing
Prepared by:
Function m-file
Eng./ Essam Nabil
MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

MATLAB Plotting
SIMATIC HMI
MATLAB
The Human
Programming
figure : is a MATLAB window that contains graphic displays.
Machine Interface
Introduction
plot :is any graphic display you can create within a figure.
Figures can contain any number of plots. Each plot is
MATLAB Basics
created within a 2-D or a 3-D data space called an axes.
Vectors & Arrays

Math. Functions
graph :is a plot of data within a 2-D or 3-D axes.
Polynomials

MATLAB plotting
To illustrate the basic components of a graph, execute the
2-D & 3-D Graphics following
Flow Control plot of a family of sine curves:
System analysis

Curve fitting x = 0:0.2:20;


Symbolic math. y = sin(x)./sqrt(x+1);
Signal processing y(2,:) = sin(x/2)./sqrt(x+1);
Function m-file y(3,:) = sin(x/3)./sqrt(x+1);
MATLAB Simulink plot(x,y)
Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

MATLAB Plotting
SIMATIC HMI
MATLAB
The Human
Programming
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Figure Toolbars
SIMATIC HMI
MATLAB Figure Toolbar : provide shortcuts to access commonly used features.
The Human
Programming
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control
Camera Toolbar :Use for manipulating 3-D views.
System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Figure Toolbars
SIMATIC HMI
MATLAB
The Human
Plot Edit Toolbar — Use for annotation and setting object properties.
Programming
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control
Note: Display the selected toolbar from the View menu
System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Axis scaling and appearance


SIMATIC HMI
MATLAB
The Human
Axis — manipulates commonly used axes properties.
Programming
Machine Interface
Introduction
>>axis([xmin xmax ymin ymax]) %limits for x-axis and y-axis
MATLAB Basics
» axis ([0 100 -50 140])
Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Axis scaling and appearance


SIMATIC HMI
MATLAB
The Human
Programming >>axis([xmin xmax ymin ymax zmin zmax ])
Machine Interface
Introduction
» axis ([0 100 -10 10 0.1 1])
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Axis scaling and appearance


SIMATIC HMI
MATLAB
The Human
Programming
>>axis auto :sets MATLAB default behavior to compute the
Machine Interface current axes limits automatically, based on the
Introduction
minimum and maximum values of x, y, and z data.
MATLAB Basics
>>axis tight :sets the axis limits to the range of the data.
Vectors & Arrays

Math. Functions
>>axis equal :sets the aspect ratio so that the data units are the
same in every direction. The aspect ratio of the x-,
Polynomials y-, and z-axis is adjusted automatically according to
MATLAB plotting the range of data units in the x, y, and z directions.
2-D & 3-D Graphics >>axis image :is the same as axis equal except that the plot box
Flow Control
fits tightly around the data.

System analysis
>>axis square :makes the current axes region square (or cubed
when three-dimensional). This option adjusts the x
Curve fitting
axis, y-axis, and z-axis so that they have equal
Symbolic math. lengths and adjusts the increments between data
Signal processing units accordingly.
Function m-file >>axis off :turns off all axis lines, tick marks, and labels.
MATLAB Simulink >>axis on :turns on all axis lines, tick marks, and labels.
Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Axis scaling and appearance


SIMATIC HMI
MATLAB
The Human
box —Axes border.
Programming
Machine Interface
>>box on :displays the boundary of the current axes.
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing
>>box off :does not display the boundary of the current axes.
Function m-file
>>box :toggles the visible state of the current axes boundary.
MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Axis scaling and appearance


SIMATIC HMI
MATLAB
The Human grid —Grid lines for 2-D and 3-D plots
Programming
Machine Interface
>>grid on :adds grid lines to the current axes.
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file
>>grid off : removes grid lines from the current axes.
MATLAB Simulink
>>grid : toggles the grid lines visibility state.
Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Types of MATLAB Plots


SIMATIC HMI
MATLAB
The Human
Two-Dimensional Plotting Functions
Programming
Machine Interface
1. Line Graphs
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Types of MATLAB Plots


SIMATIC HMI
MATLAB
The Human
Two-Dimensional Plotting Functions
Programming
Machine Interface
2. Bar Graphs
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Types of MATLAB Plots


SIMATIC HMI
MATLAB
The Human
Two-Dimensional Plotting Functions
Programming
Machine Interface
3. Area Graphs
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Types of MATLAB Plots


SIMATIC HMI
MATLAB
The Human
Two-Dimensional Plotting Functions
Programming
Machine Interface
4. Direction Graphs 5. Radial Graphs 6. Scatter Graphs
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Types of MATLAB Plots


SIMATIC HMI
MATLAB
The Human
Three-Dimensional Plotting Functions
Programming
Machine Interface
1. Line Graphs 2. Mesh & Bar Graphs
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Types of MATLAB Plots


SIMATIC HMI
MATLAB
The Human
Three-Dimensional Plotting Functions
Programming
Machine Interface
3. Area Graphs 4. Surface Graphs
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Types of MATLAB Plots


SIMATIC HMI
MATLAB
The Human
Three-Dimensional Plotting Functions
Programming
Machine Interface
5. Direction Graphs 6. Volumetric Graphs
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
1. Line Graphs
Programming
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays


plot(Y) :plots the columns of Y versus their index if Y
Math. Functions
is a real number. If Y is complex, plot(Y) is equivalent to
Polynomials
plot(real(Y),imag(Y)).
MATLAB plotting

2-D & 3-D Graphics

Flow Control x=[1 4 2 3 8];


System analysis plot(x)
Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
Programming
plot(X,Y) :plots the values of Y versus the values of X.
Machine Interface
Introduction
MATLAB Basics t=0:0.1:1;
Vectors & Arrays y=5*exp(-2*t);
Math. Functions plot(t,y)
Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting
t=0:0.05:10;
Symbolic math. y=sin(t);
Signal processing plot(t,y)
Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
Programming
plot(X1,Y1, X2,Y2, X3,Y3,…) :plots all lines defined by
Machine Interface
Introduction
Yn versus Xn pairs.
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials t=0:0.05:10;
MATLAB plotting y1=sin(t);
2-D & 3-D Graphics y2=cos(t);
Flow Control plot(t,y1,t,y2)
System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
Programming
to specify the properties of lines used for plotting use:
Machine Interface
Introduction
plot (X, Y,‘color symbol line style’ ,'linewidth', 2)
MATLAB Basics
t=linspace(-3*pi,3*pi,100);
Vectors & Arrays
y=sin(t)./t;
Math. Functions

Polynomials
plot( t, y,‘ r*:‘ ,‘ linewidth‘, 2)
MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
Color, Symbols, and Line Types:
Programming
Machine Interface
Introduction
Colors Symbols Line Types
MATLAB Basics b blue . point - solid
Vectors & Arrays g green o circle : dotted
Math. Functions r red x x-mark -. dash dot
Polynomials c cyan + plus -- dashed

MATLAB plotting
m magenta * star
y yellow s square
2-D & 3-D Graphics
k black d diamond
Flow Control
v triangle (down)
System analysis
^ triangle (up)
Curve fitting < triangle (left)
Symbolic math. > triangle (right)
Signal processing p pentagram
Function m-file h hexagram
MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
>>xlabel('string') :labels the x-axis of the current axes.
Programming
Machine Interface >>ylabel('string') :labels the y-axis of the current axes.
Introduction
>>zlabel('string') :labels the z-axis of the current axes.
MATLAB Basics

Vectors & Arrays


>>title('string') :add title to current axes.
Math. Functions
>>legend( 'string1','string2',. . . ) :displays a legend.
Polynomials

MATLAB plotting
t=0:0.05:10;
2-D & 3-D Graphics
y1=sin(t);
Flow Control
y2=cos(t);
System analysis
plot(t,y1,'b*-',t,y2,'r.:')
Curve fitting
xlabel('Time (s)')
Symbolic math.

Signal processing
ylabel('Amplitude (v)')
Function m-file
title('Sinusoidal signals')
MATLAB Simulink
legend('sin' , 'cos')
Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
>>figure :creates a new figure object .
Programming
Machine Interface >>hold on :retains the current plot and axis properties.
Introduction
>>hold off :resets the current plot and axis properties.
MATLAB Basics

Vectors & Arrays


>>hold :toggles the hold state between adding to
Math. Functions
the graph and replacing the graph.
Polynomials

MATLAB plotting
t=0:0.05:10;
2-D & 3-D Graphics
y1=sin(t);
Flow Control
y2=cos(t);
System analysis
y3=tan(t);
Curve fitting

Symbolic math.
plot(t,y1), hold on
Signal processing plot(t,y2)
Function m-file figure
MATLAB Simulink plot(t,y3)
Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
text - Create text object in current axes.
The Human
Programming
Machine Interface >>text(x,y,'string') :adds the string in quotes to the location
Introduction specified by the point (x,y) x and y must be
MATLAB Basics numbers of class double.
Vectors & Arrays >>text(x,y,z,'string') :adds the string in 3-D coordinates. x, y
Math. Functions and z must be numbers of class double.
Polynomials >>gtext('string') :displays a text string in the current figure
MATLAB plotting window after you select a location with the
2-D & 3-D Graphics
mouse.
Flow Control

System analysis

Curve fitting t=0:pi/20:2*pi;


Symbolic math. plot(t,sin(t))
Signal processing text(pi,0,‘ \leftarrow sin(\pi)’)
Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
>>[x,y] = ginput(n) : enables you to select n points from the
Programming
Machine Interface current axes and returns the x- and y
Introduction coordinates in the column vectors x and
MATLAB Basics y, respectively.
Vectors & Arrays Note:
Math. Functions [x,y] = ginput gathers an unlimited number of points .
Polynomials

MATLAB plotting
t=0:pi/20:2*pi;
2-D & 3-D Graphics
plot(t,sinc(t))
Flow Control
text(pi,0,' sinc(\pi)')
System analysis
ginput(2)
Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
Adding special characters such as Greek letters and mathematical symbols
Programming by using the backslash character (\) before the character sequence name:
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
Programming
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI clear all, close all, clc
MATLAB
The Human
Programming theta=linspace(0,2*pi);
Machine Interface
y=sinc(theta);
Introduction
plot(theta,y),grid on
MATLAB Basics
xlabel('\theta')
Vectors & Arrays
ylabel('\gamma')
Math. Functions
gtext('\fontname{courier}\fontsize{16}\bf X_{\alpha}
Polynomials
+Y^{2\pi}')
MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

2-D Graphics
SIMATIC HMI
MATLAB
The Human
Programming
Machine Interface
Introduction
MATLAB Basics
stairs(Y) :draws a stairstep graph of the elements of
Vectors & Arrays
the vector Y
Math. Functions

Polynomials
stairs(X,Y) :plots a stair step graph of the elements in Y
MATLAB plotting
at the locations specified in X.
2-D & 3-D Graphics

Flow Control

System analysis
x=0:0.25:10;
Curve fitting
y=sin(x);
Symbolic math.
stairs(x,y)
Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

End of Lecture No. “2”


SIMATIC HMI
MATLAB
The Human
Programming
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering
for internal use only Automation
Eng./ Essamand
Nabil
Drives

Questions and Discussions…!


SIMATIC HMI
MATLAB
The Human
Programming
Machine Interface
Introduction
MATLAB Basics

Vectors & Arrays

Math. Functions

Polynomials

MATLAB plotting

2-D & 3-D Graphics

Flow Control

System analysis

Curve fitting

Symbolic math.

Signal processing

Function m-file

MATLAB Simulink

Final Test Faculty of Electronic Engineering Industrial Electronics and Automatic Control Engineering

You might also like