8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
1/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction au logiciel MATLAB
Cours blocFreddy MUDRY et Michel ETIQUE
[email protected], [email protected]
ecole dingenieurs du canton de Vaud (eivd)
Departement delectricite et dinformatique
institut dAutomatisation industrielle (iAi)
Introduction au logiciel MATLABCours bloc p.1/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
2/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Organisation du "cours bloc"
8h10-9h40 Thorie, exemples dtaills
10h05-11h35 Exercices12h40-14h10 Thorie, exemples dtaills
14h20-15h50 Exercices
Documents, listings : s:\regulation\matlab\cours_bloc (du
domaine iAi) \\iai_serveur\serveur...\regulation\matlab\cours_bloc
(du domaine EINET)Introduction au logiciel MATLABCours bloc p.2/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
3/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Applications de MATLAB (eivd)
mathmatiques laboratoire de physique systmes analogiques (filtres, Bode, rponses
temporelle, etc) thorie des circuits traitement de signal rgulation automatique etc
Introduction au logiciel MATLABCours bloc p.3/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
4/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
Nombre de problmes de lingnieur ne peuvent tre rsolus que numriquement sont o doivent tre formuls de manire
matricielle=MATLAB est un logiciel spcialis dans le cal-cul matriciel numrique
Introduction au logiciel MATLABCours bloc p.4/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
5/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
oprations/manipulationsvectorielles/matricielles (inv, eig, diag)
Introduction au logiciel MATLABCours bloc p.5/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
6/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
oprations/manipulationsvectorielles/matricielles (inv, eig, diag)
rsolution (numrique) dquationsdiffrentielles (ode23 et ode45)
Introduction au logiciel MATLABCours bloc p.5/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
7/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
oprations/manipulationsvectorielles/matricielles (inv, eig, diag)
rsolution (numrique) dquationsdiffrentielles (ode23 et ode45)
cration/manipulation de polynmes(polyval, conv)
Introduction au logiciel MATLABCours bloc p.5/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
8/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
oprations/manipulationsvectorielles/matricielles (inv, eig, diag)
rsolution (numrique) dquationsdiffrentielles (ode23 et ode45)
cration/manipulation de polynmes(polyval, conv)
traitement de donnes exprimentales (min,mean, sort, std)
Introduction au logiciel MATLABCours bloc p.5/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
9/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
oprations/manipulationsvectorielles/matricielles (inv, eig, diag)
rsolution (numrique) dquationsdiffrentielles (ode23 et ode45)
cration/manipulation de polynmes
(polyval, conv) traitement de donnes exprimentales (min,mean, sort, std)
interface graphique (plot, mesh, surf)
Introduction au logiciel MATLABCours bloc p.5/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
10/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Le Workspace MATLAB
Introduction au logiciel MATLABCours bloc p.6/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
11/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Laide en ligne
help nom_de_commande
Introduction au logiciel MATLABCours bloc p.7/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
12/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
La fonction plot et loprateur .
sinc () =sin ()
th et a =l inspace (4pi ,4 pi , 1 0 0 ) ;
s i n c = sin ( t h e t a ) . / t h e t a ;
f igure ( 1 ) , plot ( th et a , sinc )
15 10 5 0 5 10 150.4
0.2
0
0.2
0.4
0.6
0.8
1
Introduction au logiciel MATLABCours bloc p.8/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
13/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Services Internet
http://www.mathworks.com
ftp.mathworks.comhttp://www.scientific.de
http://www.sysquake.com
http://www-rocq.inria.fr/scilab/
Introduction au logiciel MATLABCours bloc p.9/2
http://www.mathworks.com/http:///reader/full/ftp.mathworks.comhttp://www.scientific.de/http://www.sysquake.com/http://www-rocq.inria.fr/scilab/http://www-rocq.inria.fr/scilab/http://www.sysquake.com/http://www.scientific.de/http:///reader/full/ftp.mathworks.comhttp://www.mathworks.com/8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
14/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Botes outils
traitement de signal (signal processingtoolbox),
rgulation automatique (control systemtoolbox),
identification (system identification toolbox),
rseaux de neurones (neural networkstoolbox),
logique floue (fuzzy logic toolbox),
calcul symbolique (symbolic math toolbox),
Introduction au logiciel MATLABCours bloc p.10/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
15/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Botes outils
simulation de systmes non-linaires(Simulink),
systmes de puissance (Power Systemsblockset)
tlcommunications (Communication toolbox)
Introduction au logiciel MATLABCours bloc p.11/2
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
16/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Utilisateurs
MATLAB est un quasi-standard au niveauacadmique
Introduction au logiciel MATLABCours bloc p.12/2
U ili
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
17/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Utilisateurs
MATLAB est un quasi-standard au niveauacadmique
de plus en plus utilis par les entreprises
Introduction au logiciel MATLABCours bloc p.12/2
U ili
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
18/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Utilisateurs
MATLAB est un quasi-standard au niveauacadmique
de plus en plus utilis par les entreprises largement appci par les ingnieurs (botes
outils)
Introduction au logiciel MATLABCours bloc p.12/2
i l t i
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
19/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
uicontrol et uimenu
Introduction au logiciel MATLABCours bloc p.13/2
C ti d t d lid
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
20/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Cration daxes 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, ph i , omega ] = bode( numG, denG ) ;
%Systeme d axes p ou r re po nse f r e q u e n t i e l l e
f igure ( 1 )
axe1 = axes ( U n i t s , No rm al i ze d , . . .
P os i t i on , [ 0 . 1 , 0 . 3 , 0 . 8 , 0 . 5 ] ) ;
p l 1 = semilogx ( omega,20 log10 ( A ) ) ;
%S l i d e r pour m o d i f i ca t i o n p o s i t i o n de T
s l 1 = uicontrol ( U n i t s , N or ma l iz e d , S t y l e , S l i d e r , . . .
P o s i t i o n , [ 0 . 1 , 0 . 1 , 0 . 8 , 0 . 0 5 ] , . . .
Min , 0 . 0 0 1 , Max , 1 , Va lue , 0 . 1 , . . .
CallBack , s l ider_ch ange_ 01 ) ;Introduction au logiciel MATLABCours bloc p.14/2
F ti C llB k
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
21/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
Fonction CallBack
slider_change_01.m
%Le ctur e de l a v al eu r cou ran te du s l i d e r e t mise a j o ur de G( jw )denG = [ get ( s l 1 , V al ue ) , 1 ] ; %[T,1]
%Calcu l des r eponses
[ A ] = bode( numG, denG, omega ) ;
%Mise a j o u r du g ra p hi q ue
set ( pl1 , Ydata , l in 2d b ( A) )
Introduction au logiciel MATLABCours bloc p.15/2
MATLAB t OLE
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
22/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
MATLAB est serveur OLE
Commande de la hauteur dune sphre
e.g.
MATLAB
SIMULINK
WINDOWS
OLE
.. .
PC-PENTIUM-WINDOWS NT4. 0
RgulateurCarte
d'acquisitionNT
driver
ia
ua(t)
LaRa
Capteur de
position
ultrasons
x
0
Algorithmes,stratgie de commande,
signaux & paramtres
Interface
utilisateur
f_01_01.epsIntroduction au logiciel MATLABCours bloc p.16/2
MATLAB t OLE
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
23/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
MATLAB est serveur OLE
Panneau dinstruments virtuels
Introduction au logiciel MATLABCours bloc p.17/2
MATLAB est serveur OLE
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
24/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
MATLAB est serveur OLE
Inclusion de la librairie engine.h
#include " en gi ne . h " / / MATLAB ENGINE
Engine hMatlab ;
boo l MatlabOpened ;
Introduction au logiciel MATLABCours bloc p.18/2
MATLAB est serveur OLE
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
25/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
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 = tr ue ;}
return t r u e ;
}
Introduction au logiciel MATLABCours bloc p.19/2
MATLAB est serveur OLE
8/14/2019 Introduction Au Logiciel MATLAB Cours Bloc
26/26
A
i
i
utomatisation
n s t i t u t d '
n d u s t r i e l l e
MATLAB est serveur OLE
Transfert vers MATLAB
void Trans2MATLAB(){
mxArray T;
in t B u f f e r S i z e ;
double B u f f e r ;
B uf f e rS iz e = . . .
T = mxCreateDoubleMatrix ( Bu ff er Si ze , 2 , mxREAL);
mxSetName( T , " u_acq " ) ;B u f f e r = mxGetPr ( T ) ;
engPutArray ( hMatlab , T ) ;
m xDest r oyAr r ay( T) ;}
Introduction au logiciel MATLABCours bloc p.20/2