Vous êtes sur la page 1sur 14

Brève introduction au langage

Matlab
(Matrix Laboratory)

Renaud Séguier 20/09/2001


Brêve introduction au langage MATLAB

Brève introduction au langage


Matlab
(Matrix Laboratory)

Matlab est un langage interprété qui permet de développer des algorithmes rapidement, de
visualiser des données (sous la forme de graphiques 2D ou 3D et d'images, voir de séquences
d'images), et de réaliser des interfaces graphiques conviviales.

Cette introduction devrait vous permettre de prendre rapidement en main cet outil en vous
donnant envie d'en savoir plus :-)

I PRISE EN MAIN

I.1 Démarrage

Matlab va interpréter les commandes que vous aurez sauvegardé dans un fichier texte avec
l'extension ".m" ("toto.m" par exemple)
Il vous faut donc créer un répertoire de travail ("C:\temp\jdupont" par exemple) pour y
sauvegarder vos programmes, lancer Matlab et lui demander d'exécuter les commandes
sauvegardées dans votre fichier "toto.m".

I.2 Lancement

Pour démarrer Matlab, il suffit de cliquer dans l'icône "Matlab" si vous etes sous Windows, ou
de taper la commande matlab si vous etes sous Unix.

L'espace de travail de Matlab se présente alors sous la forme d'une fenêtre affichant un prompt
">>" à la suite duquel vous pouvez taper une commande qui sera exécutée aprés avoir tapé sur la
touche "return".
En haut de cette fenêtre se trouve une barre de menu qui vous permet d'ouvrir un fichier texte,
de définir certaines variables de travail et surtout d'accéder à l'ensemble des fichiers d'aides.

Il faut indiquer à Matlab le répertoire dans lequel vous voulez travailler (celui qui contient vos
programmes). Pour ce faire deux méthodes :

- Cliquez dans "File / Set Path / Browse" et sélectionnez votre répertoire de travail, puis
cliquez sur OK. Pour sortir de cette fenêtre, cliquez dans la croix en haut à droite ou dans la barre
de menu : File / Exit Path Brother

après le prompt « >> « de Matlab utilisez les commandes :

pwd pour connaître le nom du répertoire actif de Matlab


cd titi pour aller dans le répertoire "titi"

2 RS 20/09/2001
Brêve introduction au langage MATLAB

cd .. pour remonter d'un cran dans l'arborescence


dir pour connaître le nom des fichiers et répertoires contenus dans le répertoire
actif de Matlab

Ces commandes vous permettent de vous déplacer dans les répertoire et d'accéder au répertoire
dans lequel vous voulez rendre Mtlab actif, à savoir par exemple : "C:\temp\jdupont". Elles font
partie de la rubrique « Working with Files and the Operating Environment » du chapitre 3.

I.3 Exécution des programmes

Si Matlab est actif dans votre répertoire de travail et que celui-ci contient un fichier texte
d'extension ".m", il suffit de taper le nom du fichier après le prompt >> pour exécuter les
commandes sauvegardées dans le fichiers.

Par exemple tapez :

>> toto

Attention, vos nom de fichiers ne devront pas contenir des caractères exotiques tels que les
accents ou les espace, sinon Matlab ne pourra pas les exécuter correctement.
Veillez par ailleurs à ne pas utiliser des nom de commande trop simple. Si vous sauvegardez
votre fichier comme « max.m », lorsque vous taperez max dans la fenêtre de Matlab, il ne saura
pas s’il doit interprétez les lignes de commandes contenues dans le fichier max.m ou exécuter la
commande max (évaluation du maximum d’une matrice).
Le plus simple est de sauvegarder vos fichier en prenant comme première lettre un caractère
particulier pour éviter toute confusions, « k_toto.m » par exemple; ou d’utiliser des noms de
fichier clairement francais, « moyenne.m » par exemple.

II BREF APERCU DU LANGAGE

II.1 Premiers éléments

Avant toutes choses, votre fichier doit débuter par la la commande « clear ». Elle permet
d’effacer toutes les variables chargées dans la mémoire de Matlab.

Le fait de taper la commande

var = 3 ;

affecte à la matrice de taille 1x1 la valeur 3.

Si on omet le point-virgule à la fin de la commande, la valeur de var est affichée après


exécution.

3 RS 20/09/2001
Brêve introduction au langage MATLAB

Une portion de ligne débutant par « % » est vue comme un commentaire.

Pour interrompre une ligne d’instruction se poursuivant à la ligne suivante, taper « ... ». Par
exemple :

A = [1 2 3 4 5 ...
6 7 8]

équivaut à

A = [1 2 3 4 5 6 7 8]

II.2 Manipulation des matrices

Génération

>> A = [1 , 2 , 3 ; 4 , 5 , 6 ; 7 , 8 , 9] % La virgule (ou l’espace) sépare les colonnes,


% le point-virgule les lignes.

Ce qui donne :

A= 1 2 3
4 5 6
7 8 9

>> t = 0 : 0.2 : 2.8 % On incrémente les composantes du vecteur t de 0


% à 2.8 par pas de 0.2

t = 0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8

>> signal = sin(t) % Le sinus s’applique à chaque composantes du


% vecteur t

signal = 0 0.19 0.38 0.56 0.71 0.84 0.93 0.98 0.99 0.97 0.90 0.80 0.67 0.51
0.33

>> ZZ = [1 2 5] + i*[8 6 4] % Les valeurs d’une matrice peuvent être de type


%complexe

ZZ = 1.0 + 8.0i 2.0 + 6.0i 5.0 + 4.0i

Pour connaître la taille d’une matrice, il suffit de taper la comande « size ».

4 RS 20/09/2001
Brêve introduction au langage MATLAB

>> size (ZZ)

donnera

ans = 1 3

autrement dit une ligne sur trois colonnes

Extraction des valeurs d'une matrice A:


A(i,j) représente l'élément se trouvant sur la ième ligne, jème colonne

>> b = A(2,3)

donne

b=6

A(:,j) représente la colome n°j

>> C = A(:,2)

donne

C= 2
5
8

A(i:k,:) représente les lignes allant de i à k

>> D = A(1:2,:)

donne

D= 1 2 3
4 5 6

A(i:k , j:l) : extraction d'une sous matrice

>> E = A(2:3,2:3)

donne

5 RS 20/09/2001
Brêve introduction au langage MATLAB

E= 5 6
8 9

Construction de matrices de taille croissante

Rappelons que la virgule sépare les colonnes, le point-virgule les lignes.

>> F = [A C]

donne donc :

F= 1 2 3 2
4 5 6 5
7 8 9 8

>> G = [A ; A(2,:)]

donne

G= 1 2 3
4 5 6
7 8 9
4 5 6

>> Z = [ ] % matrice vide

On peut supprimer une colonne d'une matrice de la façon suivante

>> A(:,2) = []

donne

A= 1 3
4 6
7 9

2.3 Entrées/Sorties

E/S écran

>> x = input ( ' valeur de départ svp ' ); % Imprime la chaîne de caractère "valeur de départ

6 RS 20/09/2001
Brêve introduction au langage MATLAB

% svp" à l'écran, la valeur tapée au clavier sera alors


% affectée à x.

E/S fichier

E/S propres à Matlab

format binaire

>> save fichierl A B C % Sauvegarde A, B et C dans le fichier


% "fichierl.mat"
>> load fichierl % Charge en mémoire A, B et C sauvegardées dans
% le fichier "fichierl.mat"

format texte

Une seule matrice peut-être sauvegardée par fichier:

>> save fichier2.dat A -ascii % Sauvegarde les valeurs de A dans le ficher


% "fichier2.dat" au fomat texte
>> load fichier2.dat % Récupère les valeurs contenues dans le fichier
% "fichier2.dat" et les place dans la variable
% "fichier2"

E/S standards

Pour lire des valeurs sauvegardées sous un fomat binaire dans un fichier, une liste
d'instructions est nécessaire :

>> fidin = fopen('fichier3.dat','r'); % Ouvre le fichier "fichier3.dat" du répertoire


% courant pour le lire et initialise la variable fidin
>> Donnee = fread (fidin,2000,'uchar'); % Lis 2000 valeurs binaires sauvegardées comme
% des uchar = unsigned char, c'est à dire des valeurs
% codées sur 8 bits non signés (allant de 0 à 255) et
% les place dans le vecteur "Donnee".

>> fclose(fidin); % Ferme le pointeur affecté au fichier "fichier3.dat"

Pour sauvegarder des valeurs dans un fichier sous format binaire réutilisable par un autre
logiciel :

>> fidout = fopen('fichier4.dat','w'); % Ouvre le fichier "fichier4.dat" du répertoire


% courant en mode d’écriture binaire et initialise la
% variable fidout.

7 RS 20/09/2001
Brêve introduction au langage MATLAB

>> fwrite(fidout,Donnee,'uchar'); % Écrit les valeurs (allant de 0 à 255) de "Donnee"


% dans le fichier "fichier4.dat"

>> fclose(fidout); % Libère l'espace mémoire affecté au fichier


% "fichier4.dat"

2.4 Affichage graphique

>> plot(signal) % Pour tracer sous la forme d’une courbe les


% composantes du vecteur signal : l’axe des x
% correspond a l’indice de la composante dans le
% vecteur, l’axe des y la valeur de la composante

>> mesh(A) % Pour afficher en 3D les valeurs d'une matrice

>> title('Figure l') % Inscrit la chaîne de caractère "figure 1 " en titre au


% dessus du graphe courant.

>> subplot(dl,d2,d) % Partage l'écran en une matrice de dimension


% dl x d2 et affiche le graphe suivant cette
% commande dans la région n° d

2.5 "Debugger"

Pour connaître la liste et la taille des variables utilisées, il suffit de taper la commande "whos"
dans l'espace de travail Matlab.

Pour interrompre une liste d'instructions, tapez la commande "pause" dans le fichier
exécutable; le programme ne se poursuivra que si vous tapez sur une touche quelconque du
clavier.

Pour avoir la main dans l'environnement Matlab au cours de l'exécution d'un programme,
introduire la commande "keyboard" dans le fichier exécutable : le déroulement du programme
s'interrompt et vous pouvez observer l'état des variables. Le "prompt" est alors : "K>>". Afin de
poursuivre l'exécution du programme, taper "return" dans la fenêtre de commande de Matlab.

Pour interrompre l'exécution d'un programme, appuyer en même temps sur les touches
"Centrol" et "C".

8 RS 20/09/2001
Brêve introduction au langage MATLAB

2.6 Exemple de programme « zap.m »

clear % Efface toutes les données en mémoire

%------------------Génération des signaux---------------------------------%

FeSparc=8192; % Fréquence d'échantillonnage


% utilisée sur les stations Sun (Sparc)
TeSparc=1/FeSparc;
FreqSig=input('Fréquence du signal ?'); % Pose une question et met la réponse
% dans FreqSig (essayer 4096 = FeSparc/2)
NbEch=4096 % Nombre d'écahntillons affiché dans
% l'espace de travail Matlab (pas de ";")
t=0:TeSparc:(NbEch-1)*TeSparc; % Création d'un vecteur
Signal=sin(2*pi*FreqSig*t); % Génération du vecteur Signal
Coef=0.1;
Bruit=Coef*(2*rand(1,NbEch)-1); % rand : génération d'une matrice dont les
% composantes sont tirées aléatoirement.
SignalBruit=Signal+Bruit;

%------------------Traitement des chaînes de caractères---------------------%

FreqString=num2str(FreqSig); % Conversion d'un nombre en une chaîne


CoefString=num2str(Coef); % de caractère
chaine2=['Bruit blanc à ',CoefString,'%']% Concaténation de chaînes de
caratères
chaine1=['Signal : sinus à ',FreqString,... % Interruption de l'instruction
' Hertz'] % par le biais de "..."

%------------------Affichage graphique---------------------------------%

subplot(2,2,1); % Partition de la fenêtre graphique en une


% matrice 2x2, et sélection de la région 1
plot(Signal); % Graphe du vecteur Signal
title('Signal'); % Titre du graphique courant
sound(Signal,FeSparc); % Émission sonore du vecteur Signal
% échantillonné à la fréquence FeSparc
subplot(2,2,2);
plot(Bruit);
title('bruit');
disp('tapez sur une touche quelconque pour poursuivre');
pause
sound(Bruit,FeSparc);

subplot(2,2,3);
plot(SignalBruit);
title('signal + bruit');
disp('tapez sur une touche quelconque pour poursuivre');
pause
sound(SignalBruit,FeSparc);

subplot(2,2,4);
text('units','normalized','Position',... % Affichage de la chaine de
[0,0.75],'String',chaine2,'Color','r'); % caractère "chaine2"
text('units','normalized','Position',[0,0.25],'String',chaine1,'Color','g');
axis off % Supressions des axes de la figure
% courante

clear

9 RS 20/09/2001
Brêve introduction au langage MATLAB

desiderata=input('Vous désirez ecouter un fichier son ?','s');


delete(gcf) % Supression de la fenêtre graphique
% courante
if (desiderata=='oui')
FichierIn='_rvmaitr.wav';
[Data,freq]=wavread(FichierIn);% Récupération de la fréquence et du signal
% dans le fichier "Gong.mat"
whos % Affichage des nouvelles données en mémoire
plot(Data);
Data=-0.5+Data/max(Data);
sound(Data,freq);
end

% Lecture du fichier sys1.mat sauvegarde sous format texte

fid=fopen('sys1.mat','r');
[h,count]=fscanf(fid,'%f');
status =fclose(fid);
plot(h);

% manipulation d'image
clear
% on recupere l'image dans une matrice de dimension 3
Data=imread('im.bmp','bmp');
% des infos sur l'image
coucou=imfinfo('im.bmp','bmp')
image(Data)
% Pour avoir l'image en N&B
DataYY= 0.299*double(Data(:,:,1))+ ...
0.587*double(Data(:,:,2))+ ...
0.114*double(Data(:,:,3));
% on ne prend que les valeurs entieres
% les pixels vont de 0 a 255
DataYY=floor(DataYY);
% creation d'une palette de niveaux de gris entre 0 et 1
GrayMap=(0:255)/255;
GrayMap=[GrayMap',GrayMap',GrayMap'];
disp('taper doucement sur une touche svp');
pause
% on initialise la palette par defaut
colormap(GrayMap)
% faire un help sur image : les indices de la matrice
% allant de 0 a 255 attaquent directement les indices
% de la palette qui vont de 0 a 1 (255)
image(DataYY)
% commande suivante indispensable (voir help imwrite)
DataYY=uint8(DataYY);
% Pour sauvegarder une image sur le dsque dur :
% Attention : il FUAT que la largeur de l'image
% soit un multiple de 4 (pb windows)
imwrite(DataYY,GrayMap,'new_ima.bmp','bmp')

10 RS 20/09/2001
Brêve introduction au langage MATLAB

III LISTE DES COMMANDES

Ci-après,vous trouverez une sélection des commandes les plus utilisées. N’hésitez pas à
prendre 5 minutes pour les parcourir, cela peut vous faire gagner beaucoup de temps et vous
évitez ultèrieurement de développer du code inutile.

General Purpose Commands ( ) Parentheses


Managing Commands and Functions [ ] Brackets
help Online help for MATLAB functions and M-files {} Curly braces
helpdesk Display Help Desk page in Web browser, . Decimal point
giving access to extensive help ... Continuation
help for all commands , Comma
; Semicolon
Managing Variables and the Workspace % Comment
clear Remove items from memory ! Exclamation point
disp Display text or array ' Transpose and quote
length Length of vector .' Nonconjugated transpose
load Retrieve variables from disk = Assignment
pack Consolidate workspace memory == Equality
save Save workspace variables on disk < > Relational operators
saveas Save figure or model using specified format & Logical AND
size Array dimensions | Logical OR
who, whos List directory of variables in memory ~ Logical NOT
workspace Display the Workspace Browser, a GUI xor Logical EXCLUSIVE OR
for managing the workspace.
Logical Functions
Controlling the Command Window all Test to determine if all elements are nonzero
clc Clear command window any Test for any nonzeros
echo Echo M-files during execution exist Check if a variable or file exists
format Control the output display format find Find indices and values of nonzero elements
is* Detect state
Working with Files and the Operating isa Detect an object of a given class
Environment logical Convert numeric values to logical
cd Change working directory
copyfile Copy file Language Constructs and Debugging
delete Delete files and graphics objects MATLAB as a Programming Language
dir Directory listing eval Interpret strings containing MATLAB
ls List directory on UNIX expressions
mkdir Make directory evalc Evaluate MATLAB expression with capture.
pwd Display current directory evalin Evaluate expression in workspace
! Execute operating system command feval Function evaluation
function Function M-files
Operators and Special Characters global Define global variables
+ Plus nargchk Check number of input arguments
- Minus
* Matrix multiplication Control Flow
.* Array multiplication break Terminate execution of for loop or while loop
^ Matrix power case Case switch
.^ Array power catch Begin catch block
kron Kronecker tensor product.1-4 else Conditionally execute statements
\ Backslash or left division elseif Conditionally execute statements
/ Slash or right division end Terminate for, while, switch, try, and if
./ and .\ Array division, right and left statements or indicate last index
: Colon for Repeat statements a specific number of times

11 RS 20/09/2001
Brêve introduction au langage MATLAB

if Conditionally execute statements tic, toc Stopwatch timer


otherwise Default part of switch statement
return Return to the invoking function Matrix Manipulation
switch Switch among several cases based on cat Concatenate arrays
expression diag Diagonal matrices and diagonals of a matrix
try Begin try block fliplr Flip matrices left-right
warning Display warning message flipud Flip matrices up-down
while Repeat statements an indefinite number of times repmat Replicate and tile an array
reshape Reshape array
Interactive Input rot90 Rotate matrix 90 degrees
input Request user input tril Lower triangular part of a matrix
keyboard Invoke the keyboard in an M-file triu Upper triangular part of a matrix
menu Generate a menu of choices for user input : (colon) Index into array, rearrange array.
pause Halt execution temporarily Elementary Math Functions
abs Absolute value and complex magnitude
Object-Oriented Programming acos, acosh Inverse cosine and inverse hyperbolic
double Convert to double precision cosine
int8, int16, int32 acot, acoth Inverse cotangent and inverse hyperbolic
Convert to signed integer cotangent
uint8, uint16, uint32 acsc, acsch Inverse cosecant and inverse hyperbolic
Convert to unsigned integer cosecant
angle Phase angle
Elementary Matrices and Matrix Manipulation asec, asech Inverse secant and inverse hyperbolic
Elementary Matrices and Arrays secant
eye Identity matrix asin, asinh Inverse sine and inverse hyperbolic sine
ones Create an array of all ones atan, atanh Inverse tangent and inverse hyperbolic
rand Uniformly distributed random numbers and tangent
arrays atan2 Four-quadrant inverse tangent
randn Normally distributed random numbers and ceil Round toward infinity
arrays complex Construct complex data from real and
zeros Create an array of all zeros imaginary components
: (colon) Regularly spaced vector conj Complex conjugate
cos, cosh Cosine and hyperbolic cosine
Special Variables and Constants cot, coth Cotangent and hyperbolic cotangent
ans The most recent answer csc, csch Cosecant and hyperbolic cosecant
eps Floating-point relative accuracy exp Exponential
flops Count floating-point operations fix Round towards zero
i Imaginary unit. floor Round towards minus infinity
Inf Infinity gcd Greatest common divisor
j Imaginary unit imag Imaginary part of a complex number
NaN Not-a-Number lcm Least common multiple
nargin, nargout log Natural logarithm
Number of function arguments log2 Base 2 logarithm and dissect floating-point
pi Ratio of a circle’s circumference to its diameter,p numbers into exponent and mantissa
varargin, log10 Common (base 10) logarithm
varargout Pass or return variable numbers of mod Modulus (signed remainder after division)
arguments nchoosek Binomial coefficient or all combinations.
real Real part of complex number
Time and Dates rem Remainder after division
calendar Calendar round Round to nearest integer
clock Current time as a date vector sec, sech Secant and hyperbolic secant
cputime Elapsed CPU time sign Signum function
date Current date string sin, sinh Sine and hyperbolic sine
etime Elapsed time sqrt Square root
now Current date and time tan, tanh Tangent and hyperbolic tangent

12 RS 06/09/2000
Brêve introduction au langage MATLAB

soundsc Scale data and play as sound


Eigenvalues and Singular Values
eig Eigenvalues and eigenvectors SPARCstation-Specific Sound Functions
gsvd Generalized singular value decomposition auread Read NeXT/SUN (.au) sound file
svd Singular value decomposition auwrite Write NeXT/SUN (.au) sound file

Data Analysis and Fourier Transform Functions .WAV Sound Functions


Basic Operations wavread Read Microsoft WAVE (.wav) sound file
max Maximum elements of an array wavwrite Write Microsoft WAVE (.wav) sound file.
mean Average or mean value of arrays
median Median value of arrays Character String Functions
min Minimum elements of an array General
perms All possible permutations abs Absolute value and complex magnitude
prod Product of array elements eval Interpret strings containing MATLAB
sort Sort elements in ascending order expressions
sortrows Sort rows in ascending order real Real part of complex number
std Standard deviation strings MATLAB string handling
sum Sum of array elements
var Variance String to Number Conversion
voronoi Voronoi diagram char Create character array (string)
int2str Integer to string conversion
Finite Differences mat2str Convert a matrix into a string
del2 Discrete Laplacian num2str Number to string conversion
diff Differences and approximate derivatives. sprintf Write formatted data to a string
gradient Numerical gradient sscanf Read string under format control
str2double Convert string to double-precision value
Correlation str2num String to number conversion
corrcoef Correlation coefficients
cov Covariance matrix Low-Level File I/O Functions
File Opening and Closing
Filtering and Convolution fclose Close one or more open files
conv Convolution and polynomial multiplication fopen Open a file or obtain information about open
conv2 Two-dimensional convolution files
deconv Deconvolution and polynomial division
filter Filter data with an infinite impulse response Unformatted I/O
(IIR) or finite impulse response (FIR) filter fread Read binary data from file
filter2 Two-dimensional digital filtering fwrite Write binary data to a file

Fourier Transforms Formatted I/O


abs Absolute value and complex magnitude fgetl Return the next line of a file as a string without
angle Phase angle line terminator(s)
fft One-dimensional fast Fourier transform fgets Return the next line of a file as a string with line
fft2 Two-dimensional fast Fourier transform terminator(s)
ifft Inverse one-dimensional fast Fourier transform fprintf Write formatted data to file
ifft2 Inverse two-dimensional fast Fourier transform fscanf Read formatted data from file
unwrap Correct phase angles
File Positioning
Polynomial and Interpolation Functions feof Test for end-of-file
Polynomials ferror Query MATLAB about errors in file input or
conv Convolution and polynomial multiplication output
deconv Deconvolution and polynomial division frewind Rewind an open file
fseek Set file position indicator
Sound Processing Functions ftell Get file position indicator
General Sound Functions
sound Convert vector into sound String Conversion

13 RS 06/09/2000
Brêve introduction au langage MATLAB

sprintf Write formatted data to a string hsv2rgb Hue-saturation-value to red-green-blue


sscanf Read string under format control conversion
rgb2hsv RGB to HSVconversion
Specialized File I/O rgbplot Plot color map
imfinfo Return information about a graphics file
imread Read image from graphics file. Colormaps
imwrite Write an image to a graphics file bone Gray-scale with a tinge of blue color map
textread Read formatted data from text file contrast Gray color map to enhance image contrast
cool Shades of cyan and magenta color map
Multidimensional Array Functions copper Linear copper-tone color map
reshape Reshape array flag Alternating red, white, blue, and black color map
gray Linear gray-scale color map
Plotting and Data Visualization hot Black-red-yellow-white color map
Basic Plots and Graphs hsv Hue-saturation-value (HSV) color map
bar Vertical bar chart spring Shades of magenta and yellow color map
barh Horizontal bar chart summer Shades of green and yellow colormap
hist Plot histograms winter Shades of blue and green color map
hold Hold current graph
loglog Plot using log-log scales Printing
plot Plot vectors or matrices. print Print graph or save graph to file
semilogx Semi-log scale plot printopt Configure local printer defaults
semilogy Semi-log scale plot saveas Save figure to graphic file
subplot Create axes in tiled positions Handle Graphics, Object Creation
axes Create Axes object
Three-Dimensional Plotting figure Create Figure (graph) windows
plot3 Plot lines and points in 3-D space image Create Image (2-D matrix)
line Create Line object (3-D polylines)
Plot Annotation and Grids text Create Text object (character strings)
grid Grid lines for 2-D and 3-D plots
gtext Place text on a 2-D graph using a mouse Handle Graphics, Figure Windows
legend Graph legend for lines and patches capture Screen capture of the current figure
plotyy Plot graphs with Y tick labels on the left and clc Clear figure window
right clf Clear figure
title Titles for 2-D and 3-D plots clg Clear figure (graph window)
xlabel X-axis labels for 2-D and 3-D plots close Close specified window
ylabel Y-axis labels for 2-D and 3-D plots gcf Get current figure handle
zlabel Z-axis labels for 3-D plots newplot Graphics M-file preamble for NextPlot
property
Surface, Mesh, and Contour Plots refresh Refresh figure
contour Contour (level curves) plot saveas Save figure or model to desired output format
meshc Combination mesh/contourplot
mesh 3-D mesh with reference plane Handle Graphics, Axes
peaks A sample function of two variables axis Plot axis scaling and appearance
surf 3-D shaded surface graph cla Clear Axes
surface Create surface low-level objects gca Get current Axes handle
surfc Combination surf/contourplot
surfl 3-D shaded surface with lighting Interactive User Input
ginput Graphical input from a mouse or cursor
Domain Generation zoom Zoom in and out on a 2-D plot
griddata Data gridding and surface fitting
meshgrid Generation of X and Y arrays for 3-D plots Region of Interest
drawnow Complete any pending drawing
Color Operations
colormap Set the color look-up table

14 RS 06/09/2000

Vous aimerez peut-être aussi