Upload
hatuong
View
228
Download
0
Embed Size (px)
Citation preview
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction au logiciel MATLAB”Cours bloc”
Freddy MUDRY et Michel ETIQUE
[email protected], [email protected]
ecole d’ingenieurs du canton de Vaud (eivd)
Departement d’electricite et d’informatique
institut d’Automatisation industrielle (iAi)
Introduction au logiciel MATLAB”Cours bloc” – p.1/20
Ai
iutomatisation
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 Théorie, exemples détaillés10h05-11h35 Exercices12h40-14h10 Théorie, exemples détaillés14h20-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 MATLAB”Cours bloc” – p.2/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
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
Introduction au logiciel MATLAB”Cours bloc” – p.3/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
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
Introduction au logiciel MATLAB”Cours bloc” – p.4/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
– opérations/manipulationsvectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équationsdiffé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)
Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
– opérations/manipulationsvectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équationsdiffé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)
Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
– opérations/manipulationsvectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équationsdiffé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)
Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
– opérations/manipulationsvectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équationsdiffé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)
Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Introduction
– opérations/manipulationsvectorielles/matricielles (inv, eig, diag)
– résolution (numérique) d’équationsdiffé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)
Introduction au logiciel MATLAB”Cours bloc” – p.5/20
Ai
iutomatisation
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 MATLAB”Cours bloc” – p.6/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
L’aide en ligne
help nom_de_commande
Introduction au logiciel MATLAB”Cours bloc” – p.7/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
La fonction plot et l’opérateur .
sinc (ϑ) =sin (ϑ)
ϑ
theta = linspace (−4∗pi ,4∗ pi , 100) ;
s inc = sin ( theta ) . / theta ;
f igure ( 1 ) , plot ( theta , s inc )
−15 −10 −5 0 5 10 15−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
Introduction au logiciel MATLAB”Cours bloc” – p.8/20
Ai
iutomatisation
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.com
http://www.scientific.de
http://www.sysquake.com
http://www-rocq.inria.fr/scilab/
Introduction au logiciel MATLAB”Cours bloc” – p.9/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Boîtes à outils
– traitement de signal (signal processingtoolbox),
– régulation automatique (control systemtoolbox),
– identification (system identification toolbox),– réseaux de neurones (neural networks
toolbox),– logique floue (fuzzy logic toolbox),– calcul symbolique (symbolic math toolbox),
Introduction au logiciel MATLAB”Cours bloc” – p.10/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
Boîtes à outils
– simulation de systèmes non-linéaires(Simulink),
– systèmes de puissance (Power Systemsblockset)
– télécommunications (Communication toolbox)
Introduction au logiciel MATLAB”Cours bloc” – p.11/20
Ai
iutomatisation
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 niveauacadémique
– de plus en plus utilisé par les entreprises– largement appécié par les ingénieurs (boîtes à
outils)
Introduction au logiciel MATLAB”Cours bloc” – p.12/20
Ai
iutomatisation
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 niveauacadémique
– de plus en plus utilisé par les entreprises
– largement appécié par les ingénieurs (boîtes àoutils)
Introduction au logiciel MATLAB”Cours bloc” – p.12/20
Ai
iutomatisation
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 niveauacadémique
– de plus en plus utilisé par les entreprises– largement appécié par les ingénieurs (boîtes à
outils)
Introduction au logiciel MATLAB”Cours bloc” – p.12/20
Ai
iutomatisation
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 MATLAB”Cours bloc” – p.13/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
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
f igure (1)
axe1 = axes ( ’ Uni ts ’ , ’ Normalized ’ , . . .
’ Pos i t ion ’ , [ 0 . 1 , 0 . 3 , 0 . 8 , 0 . 5 ] ) ;
pl1 = semilogx ( omega,20∗ log10 ( A) ) ;
%Sl ide r pour mod i f i ca t i on pos i t i on de T
sl1 = uicontrol ( ’ Uni ts ’ , ’ Normalized ’ , ’ Sty le ’ , ’ S l i de r ’ , . . .
’ Pos i t ion ’ , [ 0 . 1 , 0 . 1 , 0 . 8 , 0 . 0 5 ] , . . .
’ Min ’ ,0 .001 , ’ Max’ , 1 , ’ Value ’ , 0 . 1 , . . .
’ CallBack ’ , ’ s l ider_change_01 ’ ) ;Introduction au logiciel MATLAB”Cours bloc” – p.14/20
Ai
iutomatisation
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
%Lecture de la valeur courante du s l i d e r et mise a jour de G( jw )
denG = [ get ( s l1 , ’ Value ’ ) , 1 ] ; %[T ,1 ]
%Calcul des reponses
[ A ] = bode(numG, denG, omega) ;
%Mise a jour du graphique
set ( pl1 , ’ Ydata ’ , l in2db ( A) )
Introduction au logiciel MATLAB”Cours bloc” – p.15/20
Ai
iutomatisation
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 d’une sphère
e . g .M A T L A B
S I M U L I N K
W I N D O W SO L E
. . .
P C - P E N T I U M - W I N D O W S N T 4 . 0
R é g u l a t e u rC a r t e
d ' a c q u i s i t i o nN T
d r i v e r
i a
u a ( t )
L aR a
C a p t e u r d ep o s i t i o n àu l t r a s o n s
x
0
A l g o r i t h m e s ,s t r a t é g i e d e c o m m a n d e ,s i g n a u x & p a r a m è t r e s
I n t e r f a c eu t i l i s a t e u r
f _ 0 1 _ 0 1 . e p sIntroduction au logiciel MATLAB”Cours bloc” – p.16/20
Ai
iutomatisation
n s t i t u t d '
n d u s t r i e l l e
MATLAB est serveur OLE
Panneau d’instruments virtuels
Introduction au logiciel MATLAB”Cours bloc” – p.17/20
Ai
iutomatisation
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 " engine . h" / / MATLAB ENGINE
Engine ∗ hMatlab ;
bool MatlabOpened ;
Introduction au logiciel MATLAB”Cours bloc” – p.18/20
Ai
iutomatisation
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 se ;
MatlabOpened = true ;
}
return t rue ;
}
Introduction au logiciel MATLAB”Cours bloc” – p.19/20
Ai
iutomatisation
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;
int Buf ferS ize ;
double ∗ Buf fer ;
Buf ferS ize = . . .
T = mxCreateDoubleMatrix ( Buf ferS ize , 2 , mxREAL) ;
mxSetName( T , " u_acq " ) ;
Buf fer = mxGetPr ( T ) ;
engPutArray ( hMatlab , T ) ;
mxDestroyArray ( T ) ;
}Introduction au logiciel MATLAB”Cours bloc” – p.20/20