0% found this document useful (0 votes)
48 views19 pages

Matlab Part2 Graphiques

The document discusses various types of plots that can be created in MATLAB, including: - Simple plots with one or more data series on the same graph - Customizing plot properties like line color, marker symbols, and styles - Creating polar and logarithmic plots - Generating 3D surface and mesh plots using commands like surf and mesh The document provides examples of MATLAB commands for creating different plot types and customizing their appearance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views19 pages

Matlab Part2 Graphiques

The document discusses various types of plots that can be created in MATLAB, including: - Simple plots with one or more data series on the same graph - Customizing plot properties like line color, marker symbols, and styles - Creating polar and logarithmic plots - Generating 3D surface and mesh plots using commands like surf and mesh The document provides examples of MATLAB commands for creating different plot types and customizing their appearance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Le logiciel de simulation

MATLAB
Partie 2
Graphiques

Professeur Ali Tahri


Université des sciences et de la technologie d’Oran
Mohamed Boudiaf

1
1. Graphique simple
Les commandes suivantes montrent comment afficher un graphique simple. Matlab
traite que des valeurs discrètes, il faut d’abord commencer par définir l’intervalle de
valeurs de l’abscisse puis on calcule la valeur de la fonction (dans notre cas un cosinus)
pour chaque échantillon de temps et l’on arrive au vecteur y.

2
3
>> help plot
PLOT Linear plot.
PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, disconnected
line objects are created and plotted as discrete points vertically at
X.

PLOT(Y) plots the columns of Y versus their index.


If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)).
In all other uses of PLOT, the imaginary part is ignored.

4
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram

The X,Y pairs, or X,Y,S triples, can be followed by


parameter/value pairs to specify additional properties
of the lines. For example, PLOT(X,Y,'LineWidth',2,'Color',[.6 0 0])
will create a plot with a dark red line width of 2 points.
5
For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.
PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by
the (X,Y,S) triples, where the X's and Y's are vectors or matrices
and the S's are strings.
For example, PLOT(X,Y,'y-',X,Y,'go') plots the data twice, with a
solid yellow line interpolating green circles at the data points.

The PLOT command, if no color is specified, makes automatic use of


the colors specified by the axes ColorOrder property. The default
ColorOrder is listed in the table above for color systems where the
default is blue for one line, and for multiple lines, to cycle
through the first six colors in the table. For monochrome systems,
PLOT cycles over the axes LineStyleOrder property.

If you do not specify a marker type, PLOT uses no marker.


If you do not specify a line style, PLOT uses a solid line.

PLOT(AX,...) plots into the axes with handle AX.

PLOT returns a column vector of handles to lineseries objects, one


6
handle per plotted line.
2. Graphique avancé
Matlab permet de personnaliser les graphiques. Par exemple, il est possible de changer
la couleur du trait, de marqué les points avec différents symboles tels que x, O, *,… etc.
Voici un apperçu simple de ce qui est possible de faire

7
8
3. Graphique multiple 1
Il est possible de tracer plusieurs courbes sur le même graphique. Pour ce faire, une
méthode consiste à mettre l’ensemble des fonctions à tracer dans les parenthèses qui
suivent la commande plot.

9
10
4. Graphique multiple 2
Une autre méthode pour tracer plusieurs courbes sur un même graphique consiste à
activer la commande hold on, ce qui stipule à Matlab de dessiner les graphiques les
uns sur les autres.

Il est à noter qu’à chaque fois hold on est activer, il faut la désactiver à la fin par hold
off
11
12
5. Graphique polaire
Il est aussi possible de tracer des graphiques polaires en Matlab.

13
14
6. Graphique à échelle logarithmique
Il est aussi possible de tracer des graphiques avec un ou plusieurs axes sous forme
logarithmiques en Matlab.

15
16
Il est aussi possible de tracer des graphiques à trois dimensions en Matlab.
Voici quelques exemples de commandes que vous pouvez utiliser.

>> help plot3


PLOT3 Plot lines and points in 3-D space.
PLOT3() is a three-dimensional analogue of PLOT().

PLOT3(x,y,z), where x, y and z are three vectors of the same


length,
plots a line in 3-space through the points whose coordinates
are the
elements of x, y and z.

17
>> help mesh
MESH 3-D mesh surface.
MESH(X,Y,Z,C) plots the colored parametric mesh defined by
four matrix arguments. The view point is specified by VIEW.
The axis labels are determined by the range of X, Y and Z,
or by the current setting of AXIS. The color scaling is determined
by the range of C, or by the current setting of CAXIS. The scaled
color values are used as indices into the current COLORMAP.

>> help surf


SURF 3-D colored surface.
SURF(X,Y,Z,C) plots the colored parametric surface defined by
four matrix arguments. The view point is specified by VIEW.
The axis labels are determined by the range of X, Y and Z,
or by the current setting of AXIS. The color scaling is determined
by the range of C, or by the current setting of CAXIS. The scaled
color values are used as indices into the current COLORMAP.
The shading model is set by SHADING.

18
Merci

Pour

Votre Attention

19

You might also like