Professional Documents
Culture Documents
1
2
3.
symsyms
4.
.m
5.
1zeros,eye,ones
rand
randn
linspace
Hilbert
hilb
magic
1
2
3
1.
2.
3.
union
abc = ab
intersect
abc= ab
setdiff
abC = a-b
setxor
ismember
4.
A/B
5.
exp(A) EA
6.
expm
logm
sqrtm
7.
8.
inv
9.
trace
10.
rank
det
11.
norm
norm(x,inf )
1LU
[L,U]=lu(X)
ULLU=X
2QR
[Q,R]=qr(A)
QRQRA=QR
[V,D]=eig(A)
ADVAV=VD
Matlab
M
1Matlab
2
Matlab
function
M
%Matlab
Matlab
1
>= <= >
isequal
<
&
if-else
switch-case
==
~=
4
for
while
1.
2.
narginnargout
Matlab
1.
Plot
a.
Plot (X)
b.
Plot (X,Y)
c.
Plot (X1,Y1,X2,Y2,)
d.
fPlot
limitsy=f (x)
fplot('function',limits)
functionM
xeval
tgxsinx
fplot([tan(x),sin(x)],[-1,1,0,2*pi])
axis
LineSpecMatlab
a.
-() -- () :() -. ()
b.
c.
d.
Markersize
2.
title
xlabel
ylabel
text
gtext
legend
3.
r = f ()
polar
polar(theta,rho,LineSpec)
t = 0:.01:2*pi;
polar(t,sin(3*t).*cos(2*t),'--r')
4.
pie
semilogx x
loglog
bar
barh
hist
1.
mesh
XYZ
meshgrid
[X,Y ]=meshgrid(a)
Z= f (X,Y)
mesh(X,Y,Z)
2.
contour
pie3
surf
quiver
surfnorm
Matlab
diff (S, v, n)
1.
a.
int (S, v)
b.
2.
a.
quad ( fun,a,b)
Simpson
trapz ( X, Y )
b.
dblquad ( fun,xmin,xmax,ymin,ymax)
[xmin,xmax,ymin,ymax]
z=f (x,y)
quad2ggen ( fun,xlower,xupper,ylower,yupper)
[xlower,xupper,ylower,yupper]
z=f (x,y)
.
1.
polyfit ( x, y , n)
2.
a. interp1( X,Y,xi,method)
spline
cubic
19002010
75.995
91.972
179.323 203.212
105.711
123.203
226.505 249.633
1995
131.669
150.697
256.344 267.893
1.
solve (eq)
solve (eq1,eq2,eqn)
solve('x^2+3x-6')
solve('-x^2*y+3*x-6','x+y^2-1')
2.
fzero (fun,x0)
1. Fourier
f
xfindsymFourier
F = fourier( f )
syms x
f = sin(x)*exp(-x.^2)
F = fourier(f)
eval
f = ifourier(F) Fourier
Y = fft(X)
Fourier
2. Laplace
L = L(s)
tFLaplace
L = laplace(F)
syms t
f1= sqrt(t);
L1 = laplace(f)
F = ilaplace(L)
Laplace
3. Z
F = ztrans(f )
z-
nf
1.
dsolve(eq1,eq2, )
dsolve(Dy=1+y^2,y(0)=1)
dsolve('D3u=u','u(0)=1','Du(0)=-1',
'D2u(0)=pi')
2.
ode45ode23ode113ode15sode23sde23t
ode23tb
3.
assempde
Poission
2u 1
u G 0
hyperbolic
G {(x, y) x2 y2 1}
2u 2u 2u 2u
t 2 x 2 y2 z2 0
u t 0 0
u
t 0 0
G {(x, y, z) 0 x, y, z 1}
parabolic
u 2u 2u 2u
2 2 20
y
z
t x
u G 0
G {(x, y, z) 0 x, y, z 1}
1.
fminunc ( fun, x0 ,options)
min f ( x) e x1 (4 x12 2 x22 4 x1 x2 2 x2 1)
x
2.
fmincon ( fun, x0 ,options)
1.5 x1 x2 x1 x2 0
x1 x2 10 0
fsolve(fun,x0)
2 x1 x 2 ex1
x1 2 x 2 e x 2
myfun.m
function F = myfun(x)
x0 = [-5; -5];
[x,fval] =
fsolve(@myfun,x0,optimset('fsolve'))
Matlab
VCMatlab
1.
mcc.mcpp
2.
3.
MatcomMIDEVA)
MatlabC
CMatlabMEX
1.
%Matlab%\extern
%Matlab%\extern\include\*.h
%Matlab%\extern\include\cpp\*.hpp
%Matlab%\extern\lib\win32\*.lib
%Matlab%\extern\lib\win32\microsoft\msvc60\*.lib
2. VC6
include
c/c++ mathc/c++ graphics
Tools->Options->Directories->Include files
%Matlab%\extern\include\cpp\
%Matlab%\extern\include\
MSVCMSWIND
Project->Setting->C/C++Category->Preprocessor
MSVCMSWIND
lib
%Matlab%\extern\lib\win32\libmatpm.lib
Project->Setting->C/C++Category->Code
GenerationMultithreaded DLL
3 ()
%MATLAB%\extern\lib\win32\mglinstaller.exe
*.dll
Matlab
+
*
/
\
^
.*
./
.\
.^
C++
+
*
/
C++
plus( )
minus( )
mtimes( )
mrdivide( )
mldivide( )
mpower( )
times( )
rdivide( )
ldivide( )
power( )
ctranspose( )