You are on page 1of 16

Initiation Matlab

Mathlab: Matrix laboratory (Mathworks.com)

2 Editeurs dans mathlab:


1- Editeur de ligne
>> commande
2- Editeur de page
Vecteur:
>> V=[1 2 3 4 5 6 7 8 9]
V=
1 2 3 4 5 6
>> length(v)
ans =
9
>> sum(v)
ans =
45
>> prod(v)
ans =
362880
>> max(v)
ans =

9
>> cumsum(v)
ans =
1 3 6 10
>> V1=[1:9]
V1 =
1 2 3 4
>> V2=V1'
V2 =
1
2
3
4
5
6
7
8
9
>> V3=V1+V2'
V3 =
2 4 6 8
>> V3(1,6)=0
V3 =
2 4 6 8
>> V4=ones(1,9)
V4 =
1 1 1 1
>> V5=ones(9,1)
V5 =
1
1
1
1
1
1
1
1
1
>> V6=zeros(1,9)

15 21 28 36 45

10 12 14 16 18

10

0 14 16 18

V6 =
0 0 0 0 0 0 0 0
>> V7=[zeros(1,4) 1 zeros(1,4)]
V7 =
0 0 0 0 1 0 0 0
Matrice:
>> m=[1 2 3;4 5 6;7 8 9]
m=
1 2 3
4 5 6
7 8 9
>> m1=m'
m1 =
1 4 7
2 5 8
3 6 9
>> m2=m+m1
m2 =
2 6 10
6 10 14
10 14 18
>> m3=m*m1
m3 =
14 32 50
32 77 122
50 122 194
>> m4=m.*m1
m4 =
1 8 21
8 25 48
21 48 81
>> m5=ones(4)
m5 =
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
>> m6=ones(4,3)
m6 =

1 1 1
1 1 1
1 1 1
1 1 1
>> m7=zeros(4,3)
m7 =
0 0 0
0 0 0
0 0 0
0 0 0
>> m8=eye(4)
m8 =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
>> det(m)
ans =
0
>> diag(m)
Ans =
1
5
9
>> eig(m)
ans =
16.1168
-1.1168
-0.0000
>> 1/0
ans =
Inf
>> 0/0
ans =
NaN
>> eps
ans =
2.2204e-016

Polynomes
>> p=[1 0 -3 0 0 2 -7 8 2]
p=
1 0 -3 0 0 2 -7 8 2
>> polyval(p,0)
ans =
2
>> polyval(p,1)
ans =
3
>> r=roots(p)
r=
-1.9838
-0.8613 + 1.0444i
-0.8613 - 1.0444i
1.6595
1.2193
0.5185 + 1.0149i
0.5185 - 1.0149i
-0.2093
>> q=poly(r)
q=
1.0000 0.0000 -3.0000 -0.0000 0.0000 2.0000 -7.0000 8.0000
2.0000
>> poly2str(q,'x')
ans =
x^8 + 1.9429e-016 x^7 - 3 x^6 - 5.7732e-015 x^5 + 2.8311e-015 x^4
+ 2 x^3 - 7 x^2 + 8 x + 2
Complexe
>> z=4+5i
z=
4.0000 + 5.0000i
>> z1=conj(z)
z1 =
4.0000 - 5.0000i
>> z3=sqrt(z*z1)
z3 =
6.4031

>> z4=abs(z)
z4 =
6.4031
>> atan(5/4)
ans =
0.8961
>> angle(z)
ans =
0.8961
Reprsentation graphique:
Subplot(x,y,z)
X: nombre de subdivision de lcran dans laxe horizontale x
Y : nombre de subdivision de lcran dans laxe verticale
Z : Le numro de limage partant du haut vers le bas et de gauche vers la droite

X=1 , y=4
(z : limage active)
>> subplot(1,1,1)
>> subplot(4,1,1)
>> subplot(4,1,2)
>> subplot(4,1,3)
>> subplot(4,1,4)
>> subplot(1,4,1)
Exercice 1:

>> subplot(1,1,1),grid
>> subplot(4,3,1),grid
>> subplot(4,3,[2,3]),grid
>> subplot(4,3,[4:9]),grid
>> subplot(4,3,[10,11]),grid
>> subplot(4,3,12),grid

Exercice 2:

>> subplot(7,4,[1,2,5,6])
>> subplot(7,4,[3,4,7,8])
>> subplot(7,4,[9:4:21])
>> subplot(7,4,[10,11,14,15,18,19,22,23])
>> subplot(7,4,[12:4:24])
>> subplot(7,4,25)
>> subplot(7,4,28)
>> subplot(7,4,[26,27])

Les graph 2D :

plot(continu)
Stem(discret)

Fe=1000 Hz
[300, 3400] Hz vocal Fe=8000 Hz
[5-20, 20 000] audible Fe=44100 Hz
Fe=1000 ; Te= ; N=1024
Sig1: sin (2*Pi*50*t)

Sig2 : sin (2*Pi*50*t)+sin (2*Pi*10*t)


Plot (abscisse, ordonne,couleur+format)
Noir : K ; Bleu : b
Rouge : r ; vert : g
Jaune : Y ; Bleu ciel : C
Magenta : m
Plot (t, sig1,m)
Exercice :
>> subplot(20,20,[141:280]),grid
>> subplot(20,20,[8:13]),grid
>> subplot(20,20,[26:35]),grid
>> subplot(20,20,[44:57]),grid
>> subplot(20,20,[63:78]),grid
>> subplot(20,20,[83:98]),grid
>> subplot(20,20,[102:119]),grid
>> subplot(20,20,[122:139]),grid
>> subplot(20,20,[282:299]),grid
>> subplot(20,20,[302:319]),grid
>> subplot(20,20,[323:338]),grid
>> subplot(20,20,[344:357]),grid
>> subplot(20,20,[365:376]),grid
>> subplot(20,20,[387:394]),grid

TP: sur le traitement du signal


Transform de Fourier rapide
Le pas dchantillonnage suite la rgle de shanon
fe > 2*fmax (signal)
fe = 8000Hz
fmax= 3400 Hz
fe > 2*3400 > 6800Hz
[5- 20 KHz]
fmax=20KHz
fe > 2*20KHz > 40KHz
fe=44100Hz
fe=1000 ; te=1/fe ; N=1024 ; f1=100 ; f2=200 ;f3=300
t=0 :te :1023*te
sig=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t)
f=(0 :N-1)*fe/N
fsig=fft(sig,N)
subplot(2,1,1), plot(t,sig) , axis([0.1 0.2 -2 2]),grid %reprsentions
temporelle
subplot(2,1,2),plot(f,abs(fsig))
save sig
Analyse et caractrisation des signaux reels:
.ASC
Load nom du fichier.asc
Y= nom du fichier ;
clear all
%effacer tout les valeur prcdentes
load sig
who
subplot(1,1 ,1), plot(t,sig),
axis([0.1 0.2 -2 2])

clear all
load train
who
fe=Fs
plot(y)
sound(y)
ginput(4)
sig1=y(134:4029)
plot(sig1)
sound(sig1)
f=(0:Fs-1)
fsig1=fft(sig1,Fs)
plot(f,abs(fsig1))
axis([0 Fs/2 0 350])
ginput(6)
sig2=y(4636:12807);
plot(sig2)
sound(sig2)
fsig2=fft(sig2,Fs);
plot(f,abs(fsig2))
axis([0 Fs/2 0 900]);
Format musicale
[sig,fe]=wavread('tada.wav');
plot(sig);
size(sig);
sig1=sig(:,1);
plot(sig1);
subplot(2,1,1),plot(sig1) ; %pour afficher les deux courbes
subplot(2,1,2) ,plot(sig2) ;

Filtre numrique et filtrage sur Mathlab


I- Filtre numrique : est un dispositif logique constitu dun programme qui
excute sur un processeur numrique (DSP adapt pour les excutions en temps
rel mieux que les micropross)
-filtres non rcursifs :
Il existe deux types de filtres numriques
Equation temporelle
-Filtres non rcursifs
-Filtres rcursifs

-Un filtre rcursif : la sortie dpond des entres et des sorties prcdentes
Lquation temporelle de ce filtre est donn par
a(i) et b(i) s'appellent les coefficient du filtre
Lordre du filtre est donn par P du point de vue frquentiel
La transforme de Laplace

Pour la dtermination des coefficients pour les filtres non rcursifs (on utilise les
sries de Fourier)

Avec

La transforme en Z nest appliqu que si le signal est chantillonn :

Pour les filtres non rcursifs


-on retient 2 mthodes qui sont efficaces
*invariance impulsionel
Par le calcul de la transforme en Z
*transforme bilinair

Filtre Polynmiaux
fft : faste Fourier transformer :
Soit le vecteur

sa transforme de Fourier est un vecteur W tel que:

[H,f]=freqz(num,den,1024,fe); %freqz Retourne la rponse en


frquence aux frquences "fe"
g=20*log10(abs(H));
[num1,den1]=butter(3,fcn);
[H1,f1]=freqz(num1,den1,1024,fe);
g1=20*log10(abs(H1));
[num2,den2]=butter(4,fcn);
[H2,f2]=freqz(num2,den2,1024,fe);
g2=20*log10(abs(H2));
plot(f,g,f1,g1,f2,g2),grid; axis([0 fe/2 -10 0])
__________________________________________
fe=1000 ; fc=200 ; fcn=fc/(fe/2);
[num,den]=cheby1(2,1,fcn);
[H,f]=freqz(num,den,1024,fe) ;
g=20*log10(abs(H));

D'une manire gnral pour un vecteur de n lments on peut exprimer sa


transforme de Fourier par:

Et la transforme inverse par:

Butterworth
>> [z,p,k]=buttap(2)
>> [num,den]=zp2tf(z,p,k) % partir des zros et des ples trouve la
fonction de transfert
>> [z,p,k]=buttap(3)
>> [num,den]=zp2tf(z,p,k)
Chebybichev
>> [z,p,k]=cheb1ap(2,1) %1 reprsente le taux dondulation
>> [num,den]=zp2tf(z,p,k)
>> den/1.1025
________________________________________
fe=1000 ; fc=200 ; fcn=fc/(fe/2);
[num,den]=butter(2,fcn);

[num1,den1]=cheby1(3,1,fcn);
[H1,f1]=freqz(num1,den1,1024,fe);
g1=20*log10(abs(H1));
[num2,den2]=cheby1(4,1,fcn);
[H2,f2]=freqz(num2,den2,1024,fe);
g2=20*log10(abs(H2));
plot(f,g,f1,g1,f2,g2),grid; axis([0 fe/2 -10 0])
___________________________________________
Passe bas butter (n,fcn,low)
Passe haut butter (n,fcn,high)
Passe bande butter (n ,[fcn1 fcn2])
Rejecteur de bande (n,*fcn1 fcn2+,stop)
____________________________________________
Filtre passe haut
fe=1000 ; fc=200 ; fcn=fc/(fe/2) ;
[num,den]=butter(2,fcn,'high') ;
[H,f]=freqz(num,den,1024,fe);
g=20*log10(abs(H));
plot(f,g) ; axis([0 fe/2 -10 0]),grid
____________________________________________
Filtre passe bande
fe=1000 ; fc1=200 ; fc2=300; fcn1=fc1/(fe/2) ;
fcn2=fc2/(fe/2);

[num,den]=butter(2,[fcn1 fcn2]) ;
[H,f]=freqz(num,den,1024,fe);
g=20*log10(abs(H));
plot(f,g) ; axis([0 fe/2 -10 0]),grid

____________________________________________
Filtre coupe bande
fe=1000 ; fc1=200 ; fc2=300; fcn1=fc1/(fe/2) ;
fcn2=fc2/(fe/2);
[num,den]=butter(2,[fcn1 fcn2], 'stop') ;
[H,f]=freqz(num,den,1024,fe);
g=20*log10(abs(H));
plot(f,g) ; axis([0 fe/2 -10 0]),grid

f=(0 :1023)*fe/1024 ;
fsig=fft(sig,1024) ;
[num,den]=cheby1(2,3,fcn,'high');
sig_filtre=filter(num,den,sig);
fsig_filtre=fft(sig_filtre,1024);
subplot(4,1,1),plot(t,sig),axis([0.1 0.2 -2 2])
subplot(4,1,2),plot(f,abs(fsig)),axis([0 fe/2 0 500])
subplot(4,1,3),plot(t,sig_filtre),axis([0.1 0.2 -2 2])
subplot(4,1,4),plot(f,abs(fsig_filtre)),axis([0 fe/2 0 500])

_________________________________________________________
Passe bande:

fe=1000 ; fc1=150 ;fc2=350; fcn1=fc1/(fe/2);fcn2=fc2/(fe/2)


; Te=1/fe;
t=0 :Te:1023*Te ;
fe=1000 ; fc=200 ; fcn=fc/(fe/2) ; te=1/fe;
sig=sin(2*pi*100*t)+sin(2*pi*200*t)+sin(2*pi*300*t)+sin(2*pi
t=0 :te:1023*te ;
sig=sin(2*pi*100*t)+sin(2*pi*200*t)+sin(2*pi*300*t)+sin(2*pi *400*t) ;
f=(0 :1023)*fe/1024 ;
*400*t) ;
f=(0 :1023)*fe/1024 ;
fsig=fft(sig,1024) ;
fsig=fft(sig,1024) ;
[num,den]=butter(6,[fcn1 fcn2]);
[num,den]=butter(2,fcn);
sig_filtre=filter(num,den,sig);
fsig_filtre=fft(sig_filtre,1024);
sig_filtre=filter(num,den,sig);
subplot(4,1,1),plot(t,sig),axis([0.1 0.2 -2 2])
fsig_filtre=fft(sig_filtre,1024);
subplot(4,1,2),plot(f,abs(fsig)),axis([0 fe/2 0 500])
subplot(4,1,1), plot(t,sig), axis([0.1 0.2 -2 2])
subplot(4,1,3),plot(t,sig_filtre),axis([0.1 0.2 -2 2])
subplot(4,1,2), plot(f,abs(fsig)), axis([0 fe/2 0 500])
subplot(4,1,3), plot(t,sig_filtre), axis([0.1 0.2 -2 2])
subplot(4,1,4),plot(f,abs(fsig_filtre)),axis([0 fe/2 0 500])
subplot(4,1,4), plot(f,abs(fsig_filtre)), axis([0 fe/2 0
______________________________________________________
500])
Rejecteur du bande:
__________________________________________________
fe=1000 ; fc1=150 ;fc2=350; fcn1=fc1/(fe/2);fcn2=fc2/(fe/2)
fe=1000 ; fc=150 ; fcn=fc/(fe/2) ; Te=1/fe;
; Te=1/fe;
t=0 :Te:1023*Te ;
t=0 :Te:1023*Te ;
sig=sin(2*pi*100*t)+sin(2*pi*200*t)+sin(2*pi*300*t)+sin(2*pi sig=sin(2*pi*100*t)+sin(2*pi*200*t)+sin(2*pi*300*t)+sin(2*pi
*400*t) ;
*400*t) ;
f=(0 :1023)*fe/1024 ;
f=(0 :1023)*fe/1024 ;
fsig=fft(sig,1024) ;
fsig=fft(sig,1024) ;
[num,den]=cheby1(2,3,fcn);
[num,den]=butter(6,[fcn1 fcn2],'stop');
sig_filtre=filter(num,den,sig);
sig_filtre=filter(num,den,sig);
fsig_filtre=fft(sig_filtre,1024);
fsig_filtre=fft(sig_filtre,1024);
subplot(4,1,1),plot(t,sig),axis([0.1 0.2 -2 2])
subplot(4,1,1),plot(t,sig),axis([0.1 0.2 -2 2])
subplot(4,1,2),plot(f,abs(fsig)),axis([0 fe/2 0 500])
subplot(4,1,2),plot(f,abs(fsig)),axis([0 fe/2 0 500])
subplot(4,1,3),plot(t,sig_filtre),axis([0.1 0.2 -2 2])
subplot(4,1,3),plot(t,sig_filtre),axis([0.1 0.2 -2 2])
subplot(4,1,4),plot(f,abs(fsig_filtre)),axis([0 fe/2 0 500]) subplot(4,1,4),plot(f,abs(fsig_filtre)),axis([0 fe/2 0 500])

____________________________________________

____________________________________________________
fe=1000 ; fc=350 ; fcn=fc/(fe/2) ; Te=1/fe;
t=0 :Te:1023*Te ;
sig=sin(2*pi*100*t)+sin(2*pi*200*t)+sin(2*pi*300*t)+sin(2*pi
*400*t) ;

Virgule fixe et virgule flottante


2.75 = 2 + 0.75

Alors 2.75 = (10.11)B


Q k = 5 sur une taille de n = 8 bits :
Partie entire p= n k = 3
010 | 11000
--------------------------------------------------------------------------------------------------------IEEE

Virgule flottante : (sous forme mantisse-exposant)


Lopration directe :
16.25= (10000.01)B
1.00000124 Puissance= 4
Dcalage= 2n-11
Si lexposant est exprim sur n= 8 bits
Dcalage= 271= 127
Puissance= exposant dcalage
Exposant= puissance+dcalage
=4+127
=131
=(10000011)B
Mantisse= 000001
%mantisse :partie fractionaire
Do
0100 0001 1000 0010 0000 0000 0000 0000
4
1
8
2
0
0
0
0

Lopration inverse :
Puissance = exposant dcalage
DSP TMS 320C 30
= 131 127
= 4
0
(1) 1.mantisse 2puissance (S=0)
1.000001 24 = 10000.01= 16.25
--------------------------------------------------------------------------------------------------------------------Les oprations arithmtiques en virgule flottante :
Virgule fixe :
1-Laddition :
Codage des entiers :
16.25 + 406.125 = 422.375
10000.01 + 110010110.001 = 1.00000124 + 1.10010110001 28
Codage des Rels :

Poids

16.25
-9.40625

-25
0
1

24
1
1

23
0
0

22
0
1

21
0
1

20
0
0

2-1
0
1

2-2 2-3 2-4


1 0
0
0 0
1

2-5
0
1

1.10010110001 28
+ 0.00010000010 28
-----------------------------= 1.10100110011 28
= 110100110.011

En virgule flottante :
1.0010 21
S=0
1.1001 21
Exposant = 8 + 127 = 135 =10000111
------------------0100 0011 1101 0011 0011 0000 0000 0000
1001 22
4
3
D 3
3 0
0
0
1001 . . .
2-La Soustraction :
406.125 16.25 > 0
---------------------16.25 406.125 < 0
1.1100001 22
8
1.10010110001 2
= 111.00001 = 7.03125
- 0.00010000010 28
Transforme en virgule flottante :
-----------------------------S=0
= 1.10000101111 28
Exposant = 2 +127 = 129 =10000001
(110000101.111)B =389.875
01000 0000 1110 0001 0000 0000 0000 0000
Exposant = 8 +127 =135 = 10000111
4
0
E
1
0
0
0
0
0100 0011 1100 0010 1111 0000 0000 0000
4
3
C
2
F
0
0
0
--------------------------------------------------------------------------------------------------0.00010000010 28
- 1.10010110001 28
---------------------------= 10.01111010001 28
1 : bit de signe
Aprs le dcalage : 1001111010.001
On sintresse la partie entire : 1.111010001 26
Puissance = 6
Exposant = 6 + 127 = 133 =10000101
1100 0010 1111 0100 0100 0000 0000 0000
C 2
F
4
4
0
0
0
3- La multiplication :
2.25 3.125 = 10.01 11.001 = 1.001 21 1.1001 21

1001 .

Programmation de DSP
DmarrerExecutercmd
C:\Documents and Settings\Reda>cd\
C:\>cd dsp1
C:\dsp1>asm30 1.asm 1.obj 1.lst
TMS320C3x/4x COFF Assembler Version 4.50
Copyright (c) 1987-1992 Texas Instruments Incorporated
PASS 1
PASS 2
No Errors, No Warnings
C:\dsp1>lnk30 1.obj -o 1.out
C:\dsp1>sim3x
Adressage Immdiat :
.text
ldi
22H,r0
; Charger R0 par 22H
addi 44H,R0
; Additionner 44H la valeur de R0
sti
R0,@10H ; stocker la valeur de R0 dans ladresse mmoire 10H
.end
Adressage direct :
.text
ldi
@10H,R0 ; Charger R0 par la donne de ladresse 10H
addi @11H,R0 ; Additionner R0 le contenu dadresse 11H
sti
R0,@12H ; Stocker dans ladresse 12H le contenu de R0
.end
.data
val1 .set 10H
; val1=10H
val2 .set 11H
; val2=11H
resul .set 12H
; resul=12H
.text
ldi
@val1,R0
addi @val2,R0

sti
R0,@resul
.end
.data
val1 .int 22H
val2 .int 44H
resul .space
1H
.text
ldi
@val1,R0
addi @val2,R0
sti
R0,@resul
.end
.start ".data",10H
val1 .int 22H
val2 .int 44H
resul .space
1H
.text
ldi
@val1,R0
addi @val2,R0
sti
R0,@resul
.end
Adressage indirect :
.data
adress
.word 80H
.text
ldi
@adress, AR0 ;on charge 80 dans AR0
ldi
45, R2
;on charge 45 dans R2
sti
R2, *AR0
;on stocke R2 l@pointe par AR0
ldi
55, R2
;on charge 55 dans R2
mpyi *AR0, R2
;on multiplie le contenu de l@ pointe
par AR0 par le contenu de R2
sti
R2, *+AR0(1) ;on stocke le contenu de R2 l@ qui suit
(+1) l@ pointe par AR0
.end

Les instructions de rptition


RPTS :rpter linstruction qui suit le mot rpts (RC-1) fois.
RPTB : rptera un bloc dinstructions repr par une tiquette (RC1) fois.
Exemple :
1
2
.
.
.
9
.data
tab_ad
.word tab
tab .int 1,2,3,4,5,6,7,8,9
resul .space
1
.text
Ldi @tab_ad,AR0 ; AR0 reoit l@ de la 1ere valeur
du tab (l@ ou 1 est stock)

Ldi
Ldi
Rpts
Addi

0,R0
9,RC
RC
*AR0++,R0

Sti R0,*AR0
Sti R0,@resul
.end

;
;
; Rpter 9+1 fois linstruction suivante
; additionner R0 la valeur de l@
Pointe par AR0 et incrmenter AR0

;
;

.data
tab_ad
.word tab
tab .int 1,2,3,4,5,6,7,8,9

resul .space
1
.text
Ldi @tab_ad,AR0
Ldi 0,R0
Ldi 9,RC
Rptb et
; Rpter 9+1 fois le bloc ET
et
Addi *AR0++,R0
Sti R0,*AR0
Sti R0,@resul
.end
Instruction du parallelism //
Cumul des produits
Cumul des sommes
.data
tab_ad1
.word x
tab_ad2
.word a
x
.int 1,2,3,4,5,6,7,8,9
a
.int 2,4,6,8,1,3,5,7,9
.text
Ldi @tab_ad1,AR0
Ldi @tab_ad2,AR1
Ldi 0,R0
Ldi 0,R2
Ldi 9,RC
Rpts RC
Mpyi3
*AR0++,*AR1++,R0
||Addi
R0, R2 ; Excution de deux instructions parallle
(Mpyi3||Addi).additionner R2 lancien valeur de R0 (avant Mpyi3) et met le
rsultat dans R2

Addi R0,R2
Sti R2,*AR0
.end
.data
tab_ad1
.word x
tab_ad2
.word a
x
.int 1,2,3,4,5,6,7,8,9
a
.int 2,4,6,8,1,3,5,7,9
.text
Ldi @tab_ad1, AR0
Ldi @tab_ad2, AR1
Ldi 0, R0
Ldi 0, R2
Ldi 9, RC
Rptb et
Mpyi3
*AR0++,*AR1++, R0 ; Boucle
et
Addi R0, R2
Addi R0, R2
Sti R2,*AR0
.end
.data
tab_ad1
tab_ad2
x
.int
a
.int
.text
Ldi
Ldi
ldi

.word x
.word a
1,2,3,4,5,6,7,8,9
2,4,6,8,1,3,5,7,9
@tab_ad1,AR0
@tab_ad2,AR1
1,R3

ldi
1,R0
Ldi 9,RC
Rpts RC
Addi3 *AR0++,*AR1++,R3
||Mpyi
R3,R0
Sti R0,*AR0
.end
Intercorrelation avec dcalage de 1
V1=[1 2
3
4
5
6
V2= [2
4
6
8
1
= 4+12+24+40+6+21+40+63=210
Dcalage de 2
V1=[1 2
3
4
5
6
V2=
[2
4
6
8
= 6+16+30+48+7+24+45+0+0
.data
tab_ad1
.word x
tab_ad2
.word a
x
.int
1,2,3,4,5,6,7,8,9
a
.int
2,4,6,8,1,3,5,7,9
.text
Ldi
@tab_ad1,AR0
Ldi
@tab_ad2,AR1
Ldi
0,R0
Ldi
0,R2
Ldi
8,RC
Rpts RC
Mpyi3 *AR0++,*AR1++,R0
||Addi R0,R2
Addi R0,R2
.end

7
3

8
5

9]
7

9]

7
1

8
3

9]
5

9]

Produit matriciel

tab1
tab2
A
B
resul
debut

loopi
loopj

.data
.word
.word
.int
.int
.word
.text
ldi
ldi
ldi
ldi
ldi
ldi
mpyi
Addi
Db
Sti
Ldi
subi
bnz
.end

Exemple
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D

A
B
1,2,3,4,5,6,7,8,9
1,2,3
30H
@tab1,AR0
@tab2,AR1
@resul, AR2
3, R4 ;le nombre de ligne de la matrice A
0, R0
2, AR4 ; compteurs doprations
*AR0++,*AR1++,R1
R1, R0
AR4, loopj
R0,*AR2++
@tab2, AR1
1,R4 ; soustraction R4-1
loopi

Mode dadressage circulaire


Le mode dadressage circulaire 07
1- si 0 index+pas < BK alors
Lindex = index + pas
2- si index + pas BK alors
Index= index + pas BK
>0
Si non
Index = index + pas +BK < 0

tab
x

tab
x

.data
.word
.int
.text
Ldi
Ldi
Ldi
.end
.data
.word
.int
.text
Ldi
Ldi
Ldi
Ldi
.end

x
2,6,8,0Ah,30,22,44,66,10,11,14,16,26,36
@tab,AR0
7,BK
*AR0++(5)%,R1

x
2,6,8,0Ah,30,22,44,66,10,11,14,16,26,36
@tab,AR0
7,BK
*AR0++(5)%,R1
*AR0++(4)%,R1

.data
tab
.word x
x
.int
2,6,8,0Ah,30,22,44,66,10,11,14,16,26,36
.text
Ldi
@tab,AR0
Ldi
7,BK
Ldi
*AR0++(5)%,R1
Ldi
*AR0++(4)%,R1
ldi
*AR0--(5)%,R1
.end
AR0 = B ; R1 = 2
AR0 = 08 ;R1 = 22
AR0 = 0A ; R1 = 08
x
tab

et

.text
.int
1,2,3,4,5,6,7,8,9,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh,10h,11h,12h,13h,14h,15h
.word x
Ldi
10,BK
Ldi
@tab,AR0
Ldi
99,RC
Rptb et
addi *AR0++%,R0
sti
R0,*AR0
.end

Filtres numriques non rcursifs

x
h
tab1
tab2

et

x
h
tab1
tab2

et

.text
.int
.int
.word
.word
Ldi
Ldi
Ldi
Ldi
Rptb
Mpyi3
addi
Sti
.end

1,2,3,4,5,6,7,8,9,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh
2,4,6,8,0Ah,0Ch,0Eh,1,3,5,7,9,0Bh,0Dh,0fh
x
h
@tab1,AR0
@tab2,AR1
10,BK
99,RC
et
*AR0++%,*AR1++%,R0
R0,R2
R2,*AR1

.text
.int
.int
.word
.word
Ldi
Ldi
Ldi
Rptb
Mpyi3
addi
Sti
.end

1,2,3,4,5,6,7,8,9,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh
2,4,6,8,0Ah,0Ch,0Eh,1,3,5,7,9,0Bh,0Dh,0fh
x
h
@tab1,AR0
@tab2,AR1
8,RC
et
*AR0++%,*AR1++%,R0
R0,R2
R2,*AR1

Filtre sous Matlab


Cahier de charge
Filtre RIF (FIR)
Fe=8000
FC1=300 Hz
FC2=3400 Hz
Extraction des coefficients par mathlab
Fir1(N-1,fcn,fentre)
Fir2(N-1,f,A,fenetre)
N:longueur du filter
Fc: frququence de coupure normalis
F :vecteur frquence du gabarit
A :amplitudes du filtre dans le Gabarit
Fir1 pour les 4 types des filtres
Passe bas
Cahier de charge
Fe = 8000 ; fc=1000
Programme:
fe=8000;fc=1000;fcn=fc/(fe/2);N=30;
num=fir1(N-1,fcn,blackman(N)) ;rectwin or hamming
[h,f]=freqz(num,1,1024,fe)
g=20*log10(h)
plot(f,g),axis([0 fe/2 -100 0]),grid
fe=8000;fc=1000;fcn=fc/(fe/2);N=30;
num=fir1(N-1,fcn,kaiser(N,10))
[h,f]=freqz(num,1,1024,fe)
g=20*log10(h)
plot(f,g),axis([0 fe/2 -200 0]),grid
fe=8000;fc=1000;fcn=fc/(fe/2);N=29;
num=fir1(N-1,fcn,'high',hamming(N))
[h,f]=freqz(num,1,1024,fe)
g=20*log10(h)
plot(f,g),axis([0 fe/2 -200 0]),grid

pass bande
fe=8000;fc1=300;fc2=3400;fcn1=fc1/(fe/2);fcn2=fc2/(fe/2
);N=29;
num=fir1(N-1,[fcn1 fcn2],hamming(N))
[h,f]=freqz(num,1,1024,fe)
g=20*log10(h)
plot(f,g),axis([0 fe/2 -60 0]),grid
fe=8000;fc1=300;fc2=3400;fcn1=fc1/(fe/2);fcn2=fc2/(fe/2
);N=29;
num=fir1(N-1,[fcn1 fcn2],'stop',hamming(N))
[h,f]=freqz(num,1,1024,fe)
g=20*log10(h)
plot(f,g),axis([0 fe/2 -60 0]),grid
fe=8000;fc=1000;fcn=fc/(fe/2);N=29;
ff=[0 fcn fcn 1]
A=[1 1 0 0]
num=fir2(N-1,ff,A,hamming(N));
[h,f]=freqz(num,1,1024,fe)
g=20*log10(abs(h))
plot(f,g),axis([0 fe/2 -10 0]),grid
fe=8000;fc=1000;fcn=fc/(fe/2);N=29;
ff=[0 fcn fcn 1]
A=[0 0 1 1]
num=fir2(N-1,ff,A,hamming(N));
[h,f]=freqz(num,1,1024,fe)
g=20*log10(abs(h))
plot(f,g),axis([0 fe/2 -10 0]),grid

You might also like