Professional Documents
Culture Documents
Course Objectives
Course .
1. Matlab .
2. Matlab Installation .
3. Matlab .
Matlab
Matlab Mathworks Inc. Software.
Total Solution .
OS .
display functions .
Toolbox .
script Coding .
(e.g., C/C++, Ada etc) .
Java interpreter .
device driver .(GPIB, PCI)
CPU embedded source code .
Matlab .
Matlab
.
Matlab6.1 CD 2, Matlab6.5 CD 3 .
Full Version 1[GB] .
256[MB] .
CPU Pentium-III .
, 1[GHz] 3
.
Course Objectives
Course .
1. Matlab .
2. Matlab Installation .
3. Matlab .
Matlab Installation .
Matlab Installation .
Matlab CD Installation.
Toolbox .
Toolbox : Matlab Software
. , Library
, Library Toolbox .
Toolbox : CDMA, DSP, , etc.
Installation help CD .
Matlab Installation .
Toolbox !
, NT OS install
.
2 help CD Install.
, 6.5 *.pdf files
3 CD .
Matlab .
Matlab6.0 Office 2000 .
: Install .
: Matlab (3,4,5) java .
website
.
Matlab6.1 .
: Window XP , Install
.
: .
Serial port Object Matlab Install
directory name _ .
Course Objectives
1. Matlab .
2. Matlab Installation .
3. Matlab .
Matlab .
Matlab6.5 software run-time
error .
Matlab work,
.
D:\matlabR12\Limspace
!
Matlab .
Matlab6.0, 6.1 .
Matlab6.5 .
Review Questions
Matlab software
?
Matlab .
, simulation ,
board device driver Application
Matlab
?
Matlab6.0 Office2000 .
Matlab6.1 Windows XP .
Summary
Matlab Fortran ,
Simulation tool. ,
JAVA 6.5 2002 9
.
Matlab
display function .
Matlab script OS .
Matlab Simulation Toolbox Image
Hardware Interface Solution .
, Xilinx, Altera EPLD vendor DSP,
HDL(Hardware Description Language) toolbox TI
DSP Code Composer Studio Application
. , Motolora DSP CPU toolbox ,
RTOS(Real Time OS) VxWorks toolbox
.
Course Objectives
Course .
1.
2.
3.
4.
Matlab Type.
Matlab .
Matlab .
.
Matlab Type.
Matlab Type .
ARRAY
char
NUMERIC
cell
struct
function handle
user class
java class
int8, uint8
int16, uint16
int32, uint32
single
double
sparse
Matlab Type.
Matlab
Type .
Matlab 2 3, 4,
.
type .
char : type.
cell, struct : C/C++ struct data type type.
function handle : Matlab6.X , matlab
pointer .
sparse :
.
int8, uint8, int16, uint16, int32, uint32 : matlab 64-bit
double precision . , bit
.
Course Objectives
Course .
1.
2.
3.
4.
Matlab Type.
Matlab .
Matlab .
.
Matlab .
>> (variable) = (expression)
index 1 .
(row) ; return key , (column) space bar
.
1 1 1
A 1 2 3
1 3 6
; , display .
2.1475e+009.
Matlab .
i, j .
10
1 1 1
A 1 2 3
1 3 6
Matlab .
transpose 2 .
A 1 2i 3 4i
A 1 2i 3 4i
>>X=[1+2i 3-4i]
>>X=[1+2i 3-4i].
1 2i
A
3 4i
1 2i
A
3 4i
Matlab .(dot)
.
Matlab .
C/C++ .
>>A=[-1.3 sqrt(3) (1+2+3)/5; exp(3) 4^2 -.145];
>>A(2,1)
ans =
20.0855
A , B
.
>>B=[4 1];
, error .
>>C=[A;B]
error matlab
.
Matlab .
: !
x=:: .
>> x=1:0.5:3;
x=
1.0000
1.5000
2.0000
2.5000
3.0000
end .
y=x(end)
y=
3
Course Objectives
Course .
1.
2.
3.
4.
Matlab Type.
Matlab .
Matlab .
.
Matlab .
Matlab 64bits double .
, format.m
.
) format rat, format hex
Matlab ,
, .
C/C++
.
Matlab , (true)
(False) :
(True) : nonzero
.
(False) : (Empty Matrix), zero
Matlab .
: ,
.
Matlab .
: ,
(less), (not equal to) " .
Matlab .
: "AND", "OR" , TRUE",
"FALSE" .
Matlab .
(scalar) ,
.
line
.
) >>x=1+2+3+
4+5+6
Course Objectives
Course .
1.
2.
3.
4.
Matlab Type.
Matlab .
Matlab .
.
Note
, 0.234 .234 .
line .
>>x=3; y=2; z=x+y;
.
>>x=[]
[] .
format.m
.
>> format long
>> pi
ans =
3.14159265358979
Note
Review Questions
Matlab
type ?
double, char, cell, struct, function
handle
Matlab C/C++
?
Matlab index 1.
Review Questions
Matlab : ?
.
>>x=::
Matlab .
?
.^
.*
./
Review Questions
Matlab eps
?
matlab .
Matlab
?
, ,
matlab radian
degree?
radian.
Summary
Matlab
types .
type
.
. matlab .
. : .
: transpose 2 .
, , , (True)
(False) .
Matlab C/C++ ,
: .
: M-File Programming
.
Course Objectives
Course .
1.
2.
3.
4.
5.
Matlab file .
Function Mode M-file .
Script Mode M-file .
.
debugging .
Matlab file
m file .
Course Objectives
Course .
1.
2.
3.
4.
5.
Matlab file .
Function Mode M-file .
Script Mode M-file .
.
debugging .
Function
Factorial.
Fact(n) n
factorial .
Function
workspace
, n! .
Base workspace
Course Objectives
Course .
1.
2.
3.
4.
5.
Matlab file .
Function Mode M-file .
Script Mode M-file .
.
debugging .
1
3
Script M-file
Course Objectives
Course .
1.
2.
3.
4.
5.
Matlab file .
Function Mode M-file .
Script Mode M-file .
.
debugging .
Matlab
.
if, else, elseif, end
switch, case, otherwise, end
for, end
While, end
Try, catch, end
, (true) (false)
.
.
, (true) (false)
.
switch, case if, else
program .
switch match case , case
C/C++ default
.
switch default otherwise !
for , matlab first array index 1
!
matlab C/C++ break, continue .
Course Objectives
Course .
1.
2.
3.
4.
5.
Matlab file .
Function Mode M-file .
Script Mode M-file .
.
debugging .
debugging.
, function mode m-file
function base workspace
.
Any Function M-file
function z=AnyFunc(n)
Temp=n+1;
z=Temp + 2;
function z=AnyFunc(n)
global Temp
Temp=n+1;
z=Temp + 2;
Base Workspace
Temp !
Temp !
>>Resn=10;
>>Resz=AnyFunc(Resn)
>>Temp
>>Resn=10;
>>Resz=AnyFunc(Resn)
>>global Temp
>>Temp
Review Questions
Matlab workspace
,
.
base workspace : matlab command
windows
script mode m-file
.
function workspace :
, base
workspace .
Review Questions
matlab
C/C++ ?
matlab : ~=
C/C++ : !=
Summary
Matlab m-file.
m-file script mode m-file function mode m-file .
script mode m-file , function mode mfile function .
script mode m-file matlab command window
, function mode m-file ,
function .
script mode m-file function mode m-file m-file
.
script mode m-file mcc stand-alone .
,
, , , .
inline.m
.
m-file ,
,
!
Course Objectives
Course .
1. Matlab type.
2. M-file .
Matlab type.
(double) :
matlab 2, 3 .
Matlab type.
(string) :
(, ,) .
>>s=lim jong su
Matlab ASCII Code
.
>> d=double(s(1))
d=
108
Char.m
Double.m
Matlab type.
eval.m, feval.m
.
Matlab 2 type type .
cell data type : data type .
struct data type : C data type .
cell data type
>> B.num=1:10;
Matlab type.
matlab 6.x function handle type
.
C pointer .
function x=demo(y)
function a=FHndDemo(b)
demo
demoHnd=@demo;
a=feval(demoHnd,b);
Course Objectives
Course .
1. Matlab type.
2. M-file .
M-file .
input.m prompt
. C scanf .
menu.m button GUI
.
matlab dialog .
helpdlg.m, inputdlg.m, pagedlg.m, printdlg.m,
errordlg.m, warndlg.m
M-file code pcode.m
.
>>pcode demo.m
pcode.m demo.m
demo.p .
! : , parsing
.
M-file .
inline.m :
inline object
type .
>> g=inline('t^2')
g=
Inline function:
g(t) = t^2
>> g(2)
ans =
4
Review Questions
Matlab
?
cell data type, struct data type
cell data type
?
{, }
cell data type
?
matlab type.
Review Questions
cellplot.m ?
cell
.
struct
?
function handle .
cell.m struct.m ?
Review Questions
menu.m
.
.
msgbox.m
.
.
inline.m
?
function mode m-
file .
Summary
Matlab type .
double data type.
cell data type : (, ) {, }
struct data type : (, ) .
functional handle : @
inline object
type .
cell data type, struct data type
.
cell data type .
functional handle feval.m
.
matlab (dialog) .
Course Objectives
Course .
axes Object
figure Object
Peaks
surface Object
propertyname propertyvalue .
propertyname propertyvalue
set.m, , propertyname propertyvalue
get.m .
>>set(_handle_value, propertyname,propertyvalue)
>>Propertyvalue=get(_handle_value, propertyname)
figure object
figure window ,
figure object matlab desktop .
Course Objectives
Course .
.
matlab .
2 : plot.m, contour.m, stem.m, stairs.m, pie.m, bar.m,
etc
3 : mesh.m, surf.m, contour3.m, plot3.m, etc
: polar.m, rose.m, feather.m, compass.m, etc
handle value .
3 vector volume
visualization . [ : page 384 ]
.
plot.m :
>> t=-5:1/100:5;
>> y=1./((t-.3).^2+.01)+1./((t-.9).^2+.04)-6;
>> LnHnd=plot(t,y)
LnHnd =
3.0015
>>set(LnHnd,'color','r')
set.m
line color
.
.
LnHnd line object line object
set.m, get.m .
line object .
, x, y, z
>>set(gca,xlim,[0 inf])
Grid
>>set(gca,xgrid,on,
ygrid, on)
Figure window
>>set(gcf,color,w)
.
axes object xlim, ylim, zlim
propertyname , inf ,
inf .
matlab , axes object
.
, image, axis
equal, axis image . [ 274 ]
matlab 2 figure window
. axes object , subplot.m
.
>> x=-pi:pi/20:pi;
>> subplot(1,2,1); plot(x,cos(x),'r') % line
>> subplot(1,2,2); plot(x,sin(x),'b') % .
, figure 2 axes .
.
3 2 .
, 3 vector 3
meshgrid.m.
.
3
mesh.m .
>> [X,Y]=meshgrid(-2:.25:2);
>> Z=X.*exp(-X.^2-Y.^2);
>> mesh(X,Y,Z)
.
NaN
setting .
contour.m , stem.m
discrete signal .
Figure Window menu bar View/Camera Toolbar menu
click , camera .
polar.m .
polar.m (theta,
radian) (rho) .
matlab
, X^2+y^2=3 .
.
x^2+y^2=3
matlab
. [ 402 2 ]
[ 402
2 polar.m
,
.
X^2+y^2+(z-1)^2=1
.
.
matlab 3 vector
. ,
. . 384
.
matlab animation
. comet.m
.
>> t = -pi:pi/200:pi;
>> comet(t,tan(sin(t))-sin(tan(t)))
Course Objectives
Course .
, .
matlab file / save.m,
load.m .
% base workspace .
>>load DataFile
, DataFile.mat file x, y, z
base workspace .
, .
C/C++ fopen.m, fscanf.m, fprintf.m,
fclose.m , .
, .
matlab excel toolbox . ,
excel link toolbox .
excel matlab excel link
toolbox excllink.xla excel
. , excel 3 icon .
, .
Review Questions
Matlab handle value
?
.
Matlab ?
root object(Matlab desktop ).
Review Questions
, matlab
?
text object .
universal propertyname ?
propertyname .
propertyname
?
set.m.
Review Questions
plot.m handle value
?
line object
polar.m
. ?
,
Review Questions
3
meshgrid.m
. meshgrid.m
?
2 , 3
mesh.m hidden
on/off ?
hidden off
.
Review Questions
surf.m shading.m
?
shading flat, shading interp
surf.m patch
object .
x
.
axes object
propertyname
?
xdir propertyname.
Review Questions
/ save.m,
load.m ?
*.mat file
import wizard
?
.
fopen.m, fclose.m
?
pointer
(fopen.m).
.(fclose.m)
Summary
matlab
.
, , handle value .
.
propertyname
propertyvalue .
set.m, get.m .
plot.m, mesh.m, polar.m
matlab .
rotate3d.m ,
camera .
NaN .
matlab mcc
stand alone .
/ save.m,
load.m , matlab6.X import wizard .
matlab excel, MS word toolbox .
Course Objectives
Course .
1. 2 .
2. .
2 .
analog digital :
Analog : .
Digital : , 0 1
.
Discrete : ,
.
Digital 0 1 bit ,
bit 8 bitsream byte . , 4
bitsream nibble .
AD Converter
Analog Signal
DA Converter
Digital Signal
2 .
2 .
Matlab .
hex2dec.m, dec2hex.m bin2dec.m, base2dec.m,
dec2base.m etc
2 .
Hardware firmware , 10
16 2 .
, 1 15 16 , .
>> A=1:15;
>> HexA=dec2hex(A)'
HexA =
123456789ABCDEF
, HexA array 16 !
16 123 2 .
>> Hex2Bin=double(dec2bin(hex2dec('123'),8))-48
Hex2Bin =
1
C , 48 .
2 .
2 .
, 0.6875 2
.
[ 464 LimDec2Bin.m 2
.
.
2 .
2 [ 465]
LimBin2Dec.m .
system
.
Computer .
, , , CPU Chip
, , , , CPU Chip
.
Maclaurin
.
2
.
2 .
computer 2
.
M=1010100, N=1000100 2 MN .
8bits M, N , , 8bits
. , 10000 , 0010000
. , bit , 0,
bit MSB , 0, , 1, .
, bit LSB .
Course Objectives
Course .
1. 2 .
2. .
To be continued!