Vous êtes sur la page 1sur 26

Introduction au logiciel MATLAB

”Cours bloc”
Freddy MUDRY et Michel ETIQUE
Freddy.Mudry@eivd.ch, Michel.Etique@eivd.ch

école d’ingénieurs du canton de Vaud (eivd)


Département d’électricité et d’informatique
institut d’Automatisation industrielle (iAi)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.1/20
Organisation du "cours bloc"

8h10-9h40 Théorie, exemples détaillés


10h05-11h35 Exercices
12h40-14h10 Théorie, exemples détaillés
14h20-15h50 Exercices
Documents, listings :
– s:\regulation\matlab\cours_bloc (du
domaine iAi)
– \\iai_serveur\serveur...
\regulation\matlab\cours_bloc
(du domaine EINET)
in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.2/20
Applications de MATLAB (eivd)

– mathématiques
– laboratoire de physique
– systèmes analogiques (filtres, Bode, réponses
temporelle, etc)
– théorie des circuits
– traitement de signal
– régulation automatique
– etc

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.3/20
Introduction

Nombre de problèmes de l’ingénieur


– ne peuvent être résolus que numériquement
– sont où doivent être formulés de manière
matricielle
=⇒ MATLAB est un logiciel spécialisé dans le cal-
cul matriciel numérique

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.4/20
Introduction

– opérations/manipulations
vectorielles/matricielles (inv, eig, diag)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Introduction

– opérations/manipulations
vectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équations
différentielles (ode23 et ode45)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Introduction

– opérations/manipulations
vectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équations
différentielles (ode23 et ode45)
– création/manipulation de polynômes
(polyval, conv)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Introduction

– opérations/manipulations
vectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équations
différentielles (ode23 et ode45)
– création/manipulation de polynômes
(polyval, conv)
– traitement de données expérimentales (min,
mean, sort, std)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Introduction

– opérations/manipulations
vectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équations
différentielles (ode23 et ode45)
– création/manipulation de polynômes
(polyval, conv)
– traitement de données expérimentales (min,
mean, sort, std)
– interface graphique (plot, mesh, surf)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Le Workspace MATLAB

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.6/20
L’aide en ligne

help nom_de_commande

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.7/20
La fonction plot et l’opérateur .

sin (ϑ)
sinc (ϑ) =
ϑ
t h e t a =linspace (−4∗ pi ,4∗ pi , 1 0 0 ) ;
s i n c = sin ( t h e t a ) . / t h e t a ;
f i g u r e ( 1 ) , plot ( t h e t a , s i n c )

0.8

0.6

0.4

0.2

in s t i t u t d '
−0.2

Automatisation −0.4

in d u s t r i e l l e
−15 −10 −5 0 5 10 15
Introduction au logiciel MATLAB”Cours bloc” – p.8/20
Services Internet

http://www.mathworks.com
ftp.mathworks.com
http://www.scientific.de
http://www.sysquake.com
http://www-rocq.inria.fr/scilab/

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.9/20
Boîtes à outils

– traitement de signal (signal processing


toolbox),
– régulation automatique (control system
toolbox),
– identification (system identification toolbox),
– réseaux de neurones (neural networks
toolbox),
– logique floue (fuzzy logic toolbox),
– calcul symbolique (symbolic math toolbox),

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.10/20
Boîtes à outils

– simulation de systèmes non-linéaires


(Simulink),
– systèmes de puissance (Power Systems
blockset)
– télécommunications (Communication toolbox)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.11/20
Utilisateurs

– MATLAB est un quasi-standard au niveau


académique

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.12/20
Utilisateurs

– MATLAB est un quasi-standard au niveau


académique
– de plus en plus utilisé par les entreprises

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.12/20
Utilisateurs

– MATLAB est un quasi-standard au niveau


académique
– de plus en plus utilisé par les entreprises
– largement appécié par les ingénieurs (boîtes à
outils)

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.12/20
uicontrol et uimenu

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.13/20
Création d’axes et de sliders

%D e f i n i t i o n du systeme G( jw )
T = 0.1;
numG = 1 ;
denG = [ T , 1 ] ; %[T , 1 ]
%Reponse f r e q u e n t i e l l e
[ A, phi , omega ] = bode ( numG, denG ) ;
%Systeme d ’ axes pour reponse f r e q u e n t i e l l e
figure (1)
axe1 = axes ( ’ U n i t s ’ , ’ Normalized ’ , . . .
’ Position ’ , [ 0 . 1 , 0 . 3 , 0 . 8 , 0 . 5 ] ) ;
pl1 = semilogx ( omega,20∗ log10 ( A ) ) ;
%S l i d e r pour m o d i f i c a t i o n p o s i t i o n de T
s l 1 = u i c o n t r o l ( ’ U n i t s ’ , ’ Normalized ’ , ’ S t y l e ’ , ’ S l i d e r ’ , . . .
’ Position ’ , [ 0 . 1 , 0 . 1 , 0 . 8 , 0 . 0 5 ] , . . .
’ Min ’ , 0 . 0 0 1 , ’ Max’ , 1 , ’ Value ’ , 0 . 1 , . . .
in s t i t u t d '
Automatisation ’ CallBack ’ , ’ slider_change_01 ’ ) ;
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.14/20
Fonction CallBack

slider_change_01.m
%Lecture de l a v a l e u r courante du s l i d e r et mise a j o u r de G( jw )
denG = [ get ( s l 1 , ’ Value ’ ) , 1 ] ; %[T , 1 ]

%C a l c u l des reponses
[ A ] = bode ( numG, denG, omega ) ;

%Mise a j o u r du graphique
set ( pl1 , ’ Ydata ’ , l i n 2 d b ( A) )

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.15/20
MATLAB est serveur OLE

Commande de la hauteur d’une sphère


C a p t e u r d e

p o s i t i o n à

u l t r a s o n s

R a
L a

P C - P E N T I U M - W I N D O W S N T 4 . 0 u a
( t )

i a

. . .
e . g . A l g o r i t h m e s ,
M A T L A B
s t r a t é g i e d e c o m m a n d e ,
S I M U L I N K
s i g n a u x & p a r a m è t r e s

C a r t e

in s t i t u t d ' W I N

O
D

L
O

E
W S

u
I n t e

t i l i s a
r f a

t e
c

u
e

r
R é g u l a t e u r
d
N

r i v
T

e r
d ' a c q u i s i t i o n

Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.16/20
f _ 0 1 _ 0 1 . e p s
MATLAB est serveur OLE

Panneau d’instruments virtuels

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.17/20
MATLAB est serveur OLE

Inclusion de la librairie engine.h

# include " engine . h " / / MATLAB ENGINE


Engine ∗ hMatlab ;
bool MatlabOpened ;

in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.18/20
MATLAB est serveur OLE

Ouverture de MATLAB

bool MatlabOpen ( void )


{
i f ( ! MatlabOpened )
{
hMatlab = engOpen( " \ 0 " ) ;
i f ( hMatlab = = NULL) return f a l s e ;
MatlabOpened = t r u e ;
}
return t r u e ;
}
in s t i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.19/20
MATLAB est serveur OLE

Transfert vers MATLAB


void Trans2MATLAB ( )
{
mxArray ∗ T ;
int BufferSize ;
double ∗ B u f f e r ;

BufferSize = . . .
T = mxCreateDoubleMatrix ( B u f f e r S i z e , 2 , mxREAL) ;
mxSetName( T , " u_acq " ) ;
B u f f e r = mxGetPr ( T ) ;

engPutArray ( hMatlab , T ) ;
mxDestroyArray ( T ) ;
i n s t}i t u t d '
Automatisation
in d u s t r i e l l e Introduction au logiciel MATLAB”Cours bloc” – p.20/20

Vous aimerez peut-être aussi