Professional Documents
Culture Documents
Mat
Mat
MATLAB
------------------------------------------------------------
13
15
1.4 , --------------------------------------------------------------
16
1.5 -------------------------------------------------------------------
17
1.6 ---------------------------------------------------------------
19
1 --------------------------------------------------------------------------------------
31
-----------------------------------------
34
2.1 ? ------------------------------------------------------------
34
2.2 ---------------------------------------------------
34
2.3 ------------------------------------------------------------------------
35
2.4 ---------------------------------------------------------------------
37
2.5 ------------------------------------------------------------------------
39
40
41
2 --------------------------------------------------------------------------------------
43
---------------------------------------------------------
45
3.1 ---------------------------------------------------------
45
45
47
48
49
50
3.2 -----------------------------------------------------------------
53
54
3.4 ---------------------------
56
3 -------------------------------------------------------------------------------------
59
------------------------------------------------------------------
67
67
71
4.2.1 ------------------------------------------------------------------
71
78
4 -------------------------------------------------------------------------------------
82
---------------------------------
86
86
5.2 -----------------------------------------------
86
5.3 -----------------------------------------------------------------
88
5.4 ---------------------
89
5 -------------------------------------------------------------------------------------
91
z- (z-Transform)
------------------------------------------------------
94
6.1 z- ----------------------------------------------------------------------
94
94
6.1.2 z- -----------------------------------------------------------
96
6.1.3 ------------------------------------------------
97
6.2 ------------------------------------------------------------------------
99
101
6.4 ------------------------------------------------------------------------
105
107
109
6 -------------------------------------------------------------------------------------
113
--------------
121
7.1 --------------------------------------------------------------
121
7.2 -----------------------------------------------------------
122
122
130
7.4.1 -----------------------------------------------
130
7.4.2 ------------------------------------------------
133
134
7.6 ------------------------------------------------------
136
139
139
7 -------------------------------------------------------------------------------------
H/W
144
-------------------------------------------------
155
8.1 ---------------------
155
156
157
157
158
159
159
160
161
162
8 -------------------------------------------------------------------------------------
164
FIR
--------------------------------------------------------------
177
9.1 -----------------------------------------------------------
177
9.1.1 --------------------------------------------
178
180
181
9.2.1 --------------------------------------------------------
181
9.2.2 -----------------------------------------------------------------
183
9.2.3 ------------------------------
187
9 -------------------------------------------------------------------------------------
190
10
IIR
-------------------------------------------------------------
204
10.1 ------------------------------------------------------------
205
10.2 -----------------------
212
212
214
10.2.3 -----------------------------------------------------
215
10 -----------------------------------------------------------------------------------
217
11
(Adaptive Filter)
-------------------------------------------
238
11 -----------------------------------------------------------------------------------
12
241
---------------------------------------------
247
1 -------------------------------------------------------------------------------------
247
13
---------------------------------------------
250
2 -------------------------------------------------------------------------------------
250
14
---------------------------------------------
253
3 -------------------------------------------------------------------------------------
253
---------------------------------------------------------------------------------------
258
1 MATLAB
MATLAB .
MATLAB MATLAB
Toolbox .
MATLAB
MATLAB C C++
. ,
MATLAB C C++ , DSP
TMS320
Mathworks MATLAB
.
.
Mathworks
C++
2. TI TMS320C6000 Motolora M6800
3. Xilinx ALTERA EPLD(FPGA) HDL
4. x-PC MABLAB Emulation
1. C
Simulink
Labview MATLAB
.
MATLAB .
MATLAB ,
MATLAB .
MATLAB
1. Steven W. Smith, "The Scientist and Engineer's Guide to Digital Signal Processing"
2. Vinay K. Ingle, John G. Proakis, "Digital Signal Processing using the MATLAB"
3.
1.1 MATLAB
. 1-1
(matrix) (transpose) .
'
) a' , A'
.
' '
) title('Magnitude')
, .
[ ]
) a=[1 3 5 7]
, (function)
( )
.
) a(1,2), max(a)
;
.
) a=sqrt(2)+exp(3);
.
:
) t=[0:0.01:1];
.
.
) c=a.^2 , c=a./b
%
(comment line) .
.
. .
>>
(variable) = (expression)
. 1-2
pi
3.1415926535897...
), , , i j
(,
j
.
(infinity) .
inf
( nonzeros ) / 0
(Not-a-number) .
NaN
0 / 0 inf / inf
1)
>>A=[1 4 8 6]
A =
1
>>A=[1; 4; 8; 6;]
A =
1
4
8
6
>>a=[1:4:1]
4 1
% 1
a =
1
>>a=[9:-2:1]
1 -2
% 9
a =
9
2)
%
%
, .
>>A=
A =
3)
b=[4 5 6];
>> c= a.* b
c =
4
10
18
b=[-4 5 -6 2];
36
42
36
ans =
3
4)
10
1.7321
0.8000
'x'
>>x(3)
'( )'
(subscript)
ans =
0.8000
>> a=[1 2 3; 4 5 6; 7 8 9]
a =
1
>> a(1,3)
ans =
3
>> a(2,2)
ans =
5
>> a(3,2)
ans =
8
>> a(1,:)
% 1
ans =
1
>> a(:,2)
% 2
ans =
2
5
8
2,3
>> a(3,2:3)
% 3
ans =
8
10
2,3
>> a(2:3,2)
% 2
ans =
5
8
, ... .
>> P=[1, 2, 4, 6, 8]+[pi, 4, exp(1), 0, -1]+...
[cos(0.1*pi), sin(pi/3), tan(3), atan(2), sqrt(pi)]
P =
5.0926
5)
6.8660
6.5757
7.1071
8.7725
10
12
15
3 -22.999
>> a(1,3)=22.999
% 1
a =
1.0000
2.0000
22.9990
4.0000
5.0000
2.0000
4.0000
6.0000
8.0000
10.0000
3.0000
6.0000
9.0000
12.0000
15.0000
>> a(2,6)=-88.999
6 -88.999
% 6 6 .
% 2
a =
1.0000
2.0000
22.9990
4.0000
2.0000
4.0000
6.0000
8.0000
3.0000
6.0000
9.0000
12.0000
>> a(3,5)=-55
5.0000
10.0000 -88.9990
15.0000
5 -55
% 3
a =
1.0000
2.0000
22.9990
4.0000
11
5.0000
2.0000
4.0000
6.0000
8.0000
3.0000
6.0000
9.0000
12.0000
>> b=2*a
% a
10.0000 -88.9990
-55.0000
b =
6)
2.0000
4.0000
45.9980
8.0000
10.0000
4.0000
8.0000
12.0000
16.0000
6.0000
12.0000
18.0000
24.0000 -110.0000
20.0000 -177.9980
0
(transpose : ij ji )
x " z' " (complex conjugate) .
x " z.' " .
" . (dot) " .
>>z=[1+2i 3+4i]
z =
1.0000 + 2.0000i
>>z'
3.0000 + 4.0000i
ans =
1.0000 - 2.0000i
3.0000 - 4.0000i
>>z.'
ans =
1.0000 + 2.0000i
3.0000 + 4.0000i
12
1.2
1)
(operators)
(Arithmetic Operators)
1. transpose( " .' " ), power ( " .^ " ),
>>A=[3 9 5];
>>B=[2 1 5];
>>C=A./B.^2
% B.^2
C =
0.7500
9.0000
0.2000
2)
, A./ .
(Relational operators)
0 .
.123 .
A B , A B (TRUE)
1 , (:FALSE) 0 .
, A B
.
.
, . ,
, , " find "
, .
" find "
>>A=magic(4) % magic
A =
16
2
3
13
5
11
10
8
9
7
6
12
4
14
15
1
>>index=find(A > 8);
>>A(index)=100
A =
100
2
3 100
5 100 100
8
100
7
6 100
4 100 100
1
14
3)
(Logical Operators)
"AND", "OR"
TRUE", "FALSE" .
. 1-4
1.3 MATLAB
&
AND
OR
NOT
sin(x) / cos(x) / tan(x) / asin(x) / acos(x) / atan(x) / exp(x) / log(x) / log10(x) /
sqrt(x) / abs(x) / phase(x) / real(x) / imag(x) / conj(x) / mean(x) / std(x) / sum(x)
/
max(x) / min(x) / ceil(x) / floor(x) / round(x) / rem(x,y) / fix(x) / length(x) /
size(x) / ones(rn,cn) / zeros(rn,cn) / eye(rn,cn) / linspace(sn,incn,en) / pi(=3.14159....)
x=3+3j or x=3+3i or x=3+3*j or x=3+3*i
clear all;
close all;
clc;
disp('DSP')
15
1.4
,
save
1) load
, save.m, load.m .
save.m *.mat file ,
load.m *.mat file .
MATLAB
, x, y, z DataFile.mat file
.
>>clear all
% base workspace
>>load Data_file
.
2) Low_level file I/O
fclose.m
.
fopen.m
16
/ascii
: ascii
fscanf.m
, .
fprintf.m
3) input
input
a= ')
a= 6
>> a=input('
a =
6
>> x=a+a.^2;
>> x
x =
42
1.5
1) FOR
for i = 1:10
end
x=0;
for i = 1:10
x=x+i;
end
x
x =
55
2) IF
if (
)
;
elseif
;
17
else
end
3) WHILE
while (
end
n=1;
while (prod(1:n)<1000)
n=n+1;
end
n
n =
7
18
4) SWITCH
case 1,
;
case 2,
;
switch
.....
otherwise
case
end
x=input('
x=')
y=rem(x,2);
switch y
case 1,
disp('
case 2,
disp('
')
')
end
x=45
x =
45
1.6
MATLAB
19
.
.
MATLAB
PLOT
1)
>> t=[0:0.1:2*pi];
>> y=sin(t);
>> plot(t,y)
20
"plot"
stem"
21
2)
>> t=[0:0.1:2*pi];
>> y=sin(t);
>> z=cos(t);
>> plot(t,y,t,z)
3) hold
>> hold on
, hold on
>> hold off
22
>>
>>
>>
>>
>>
>>
x=0:.1:2*pi;
y=sin(x);
plot(x,y)
grid on
hold on
plot(x,exp(-2*x),'r:*')
STEM
>> n=[0:0.2:2*pi];
>> y=sin(n);
>> stem(n,y)
>> stem(n,y,'filled')
23
log
x, y log ,
.
>>w=logspace(-2,2,1000);
>>H=1./(1+w.^2).^0.5;
>>subplot(1,3,1),semilogx(w,H);
>>subplot(1,3,2),semilogy(w,H);
>>subplot(1,3,3),loglog(w,H);
, , )
subplot(
>>
>>
>>
>>
>>
subplot(2,2,1),
x = 0:.1:2*pi;
subplot(2,2,2),
subplot(2,2,3),
subplot(2,2,4),
plot(1:10)
plot(x,sin(x))
plot(x,exp(-x),'r')
plot(x+sin(x)+exp(-x),'k')
24
'option' .
>> plot(x,y,'option')
>> x = 0:.1:2*pi;
>> plot(x,sin(x),'r--d')
25
. 1-5 option
option
option option
blue
point
solid
green
circle
dotted
red
x-mark
-.
dashdot
cyan
plus
--
dashed
magenta
star
yellow
square
black
diamond
triangle
(down)
triangle(up)
<
triangle(left)
>
triangle(right)
pentagram
hexagram
26
>>
>>
>>
>>
>>
x = 0:.1:2*pi;
plot(x,sin(x),'r--d');
xlabel('Frequency(w)');
ylabel('Amplitude[V]');
title('SIN function');
1)
27
. 1-6.
28
Property Editor
1) Figure Property
2) Axes Property
29
30
1
MATLAB .
1.
MATLAB
2.
MATLAB
MATLAB
MATLAB
MATLAB ,
3.
(1)
MATLAB meditor .
.
(2) MATLAB
(3)
31
1]
. , .
[
2] sin cos
. y1 y2 .
[
32
3] sin cos
save ASCII . load
,
. "o" .
[
4] "input" a,b,c,d,e
log c) d) e)
a) b)
MATLAB . .
[
33