Professional Documents
Culture Documents
tw
(02)2705-5066
www.wunan.com.tw
(02)2705-5066
www.wunan.com.tw
(02)2705-5066
www.wunan.com.tw
(02)2705-5066
51
www.wunan.com.tw
(02)2705-5066
93
www.wunan.com.tw
(02)2705-5066
159
Z
Z
Z
Z
Z
Z
www.wunan.com.tw
(02)2705-5066
193
www.wunan.com.tw
(02)2705-5066
IIR
233
FIR
289
www.wunan.com.tw
(02)2705-5066
337
www.wunan.com.tw
(02)2705-5066
MATLAB
353
10
MATLAB
397
www.wunan.com.tw
(02)2705-5066
11
MATLAB
427
www.wunan.com.tw
(02)2705-5066
www.wunan.com.tw
(02)2705-5066
1.
M_Lint
M
2.
3.
Fast Fourier Transform, FFT
Linsolve
Ordinary Differential Equation, ODE
2 www.wunan.com.tw
(02)2705-5066
1.1
MATLAB 7.0
4.
M
M
5.
GUIDE ActiveX
6.
Excel HDF5
.mat
MATLAB Javaaddpath
Java
COM Visual Basic Script
SOAP
FTP FTP
Unicode .mat
MATLAB 7.0
1-1
Start
www.wunan.com.tw 3
(02)2705-5066
1-1 MATLAB
1.
MATLAB 7.0 Unlock Command Window
1-2
2.
4 www.wunan.com.tw
(02)2705-5066
1.1
MATLAB 7.0
1-3
M
3.
1-4
4.
MATLAB
1-5
www.wunan.com.tw 5
(02)2705-5066
M .m M
MATLAB
MATLAB M M
1. M
M 1-6
1-6 M
M
1FileNewM-File
2edit M
3
M
1FileOpen
2 M
3
4 M
1-7 M
6 www.wunan.com.tw
(02)2705-5066
1.1
MATLAB 7.0
1-7 M
2.
MATLAB M
MATLAB
function
HI lookfor
HI
%
1-1 sign
1
x>0
sign =
0
1
x=0
x<0
www.wunan.com.tw 7
(02)2705-5066
M
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-1 M funsign.m
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function f=funsign(x)
%
%
%HI
%
if x>0
f=1;
elseif x== 0
f=0;
else
f= -1;
end
3.
MATLAB
MATLAB
MATLAB M
MATLAB clear
MATLAB
M
function
8 www.wunan.com.tw
(02)2705-5066
1.2
MATLAB
1-2 M
% %%%%%%%%%%%%%%%%%%%%%%%%%
% 1-2
% %%%%%%%%%%%%%%%%%%%%%%%%%
clc;clear;close all;
x=-2*pi:0.01:2*pi;
y=sin(x);
plot(x,y);
1-8
1-8
www.wunan.com.tw 9
(02)2705-5066
for
for =
end
1-3 sum =
10
i=1
x 2
% %%%%%%%%%%%%%%%%%%%%%%%%%
% 1-3 sum =
10
i=1
x2
% %%%%%%%%%%%%%%%%%%%%%%%%%
clc;close all;clear all;
sum=0;
for i=1:10
sum=sum+i^2;
end
sum
385
2. while
while for
while
while
10
www.wunan.com.tw
(02)2705-5066
1.2
MATLAB
while
break
sum
20
www.wunan.com.tw 11
(02)2705-5066
1. if-else-end
(1)
if
end
(2)
if
1
else
2
end
(3)
if 1
1
elseif 2
2
......
else
k
end
12
www.wunan.com.tw
(02)2705-5066
1.2
MATLAB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-5 if-else-end |a|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=fabs(x)
%
if x>=0
y=x;
else
y= -x;
end
2. switch-case-otherwise
switch-case-otherwise
switch expression
case value1
statements1;
case value2
statements2;
......
case valuem
statementsn;
otherwise
statements;
end
www.wunan.com.tw 13
(02)2705-5066
1-6 switch-case-otherwise
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-6 switch-case-otherwise
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all;clear all;clc;
for i=1:10
a{i}=89+i;b{i}=79+i;c{i}=69+i;d{i}=59+i;
end
c=[d,c];
Name={'','','','',''};Mark={61,97,57,76,49};
Rank=cell(1,5);S=struct('Name',Name,'Marks',Mark,'Rank',Rank);
for i=1:5
switch S(i).Marks
case 100
S(i).Rank='';
case a
S(i).Rank='';
case b
S(i).Rank='';
case c
S(i).Rank='';
otherwise
S(i).Rank='';
end
end
disp(['',blanks(9),'',blanks(9),'']);disp(' ')
for i=1:5
disp([S(i).Name,blanks(10),num2str(S(i).Marks), blanks(10), S(i).Rank])
end
61
97
57
76
49
14
www.wunan.com.tw
(02)2705-5066
1.3
MATLAB
1-1
1-1
(1)square
Square
x=square(t) 2 1
x=square(t,duty)1 duty
1-7 square 1 50% 30%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-7
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:0.01:4;
y1=square(2*pi*t);
y2=square(2*pi*t,30);
subplot(2,1,1);plot(t,y1);
subplot(2,1,2);plot(t,y2);
1-9
www.wunan.com.tw 15
(02)2705-5066
1-9
(2)sawtooth
sawtooth
x=sawtooth(t) 2 1
x=sawtooth(t,width) width
width
1-8 sawtooth 1
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-8 sawtooth 1
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:0.01:4;
y1=sawtooth(2*pi*t);
y2=sawtooth (2*pi*t,0.5);
subplot(2,1,1;plot(t,y1);
subplot(2,1,2;plot(t,y2);
1-10
(3)sinc
sinc
x=sinc(t)
16
www.wunan.com.tw
(02)2705-5066
1.3
MATLAB
sinc
1-9 sinc
% %%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-9 sinc
% %%%%%%%%%%%%%%%%%%%%%%%%%%%
t=-5:0.01:5;
y=sinc(t);
plot(t,y);
1-11
1-10
1-11 sinc
(4)diric
diric
x=diric(x,n)
n 2 n 4
1-10 diric
www.wunan.com.tw 17
(02)2705-5066
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-10 diric
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:0.001:10*pi;
y1=diric(t,4);
y2=diric(t,5);
subplot(2,1,1);plot(t,y1);
subplot(2,1,2);plot(t,y2);
1-12
1-12 diric
(5)rectpuls
rectpuls
x=rectpuls(t)
t=0
x=rectpuls(t,w)
w
1-11 rectpuls 1s 0.7s
18
www.wunan.com.tw
(02)2705-5066
1.3
MATLAB
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-11 rectpuls 1s 0.7s
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:0.01:1;
y=rectpuls(t,0.7);
plot(t,y);
1-13
1-13 rectpuls
(6)tripuls
tripuls
x=tripuls(t)
t=0
x=tripuls(t,width)
width
x=tripuls(t,width,s)
s
1-12 tripuls 1s 0.6s 0 0.9
www.wunan.com.tw 19
(02)2705-5066
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-12 tripuls 1s 0.6s 0 0.9
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:0.01:1;
y1=tripuls(t,0.6);
y2=tripuls(t,0.6,0.9);
subplot(2,1,1);plot(t,y1);
subplot(2,1,2);plot(t,y2);
1-14
(7)pulstran
pulstran
x=pulstran(t,d,'func')
func gauspulsrectpuls
tripuls d func
x= pulstran(t,d,'func',p1,p2)
p1 p2 func
x= pulstran(t,d,p,Fs)
p Fs
1-13 pulstran
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1-13 pulstran
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:1/1e3:1;
d=0:1/3:1;
y=pulstran(t,d,'tripuls');
plot(t,y);
1-15
20
www.wunan.com.tw
(02)2705-5066
MATLAB . .
, 2012.08
I S B N: 978-957-11-6742-8
1.MATLAB 2.
448.7
101013813
5DF0
MATLAB
106 339 4
(02)2705-5066
http://www.wunan.com.tw
(02)2706-6100
wunan@wunan.com.tw
0106 8953
/ 6
(04)2223-0891
(04)2223-3549
/ 290
(07)2358-702
2012 8
(07)2350-236
540
(02)2705-5066
www.wunan.com.tw