第1章 MATLAB 6read.pudn.com/downloads154/ebook/684408/MbookMATLAB.doc · Web...
Transcript of 第1章 MATLAB 6read.pudn.com/downloads154/ebook/684408/MbookMATLAB.doc · Web...
1 MATLAB 6
1 MATLAB 6.5
1.1 MATLAB
MATLAB(Matrix Laborator)MathWorks
MATLIB MATLIB 6.5
1.1.1 MATLAB
MATLAB
MATLAB
MATLAB
MATLAB
(Control System Toolbox)
(System Identification Toolbox)
(Signal Processing Toolbox)
(Neural Network Toolbox)
(Fuzzy Logic Toolbox)
(Wavelet Toolbox)
(Model Predictive Control Toolbox)
(Communication Toolbox)
(Image Processing Toolbox)
(Frequency System Identification Toolbox)
(Optimization Toolbox)
(Partial Differential Equation Toolbox)
(Financial Toolbox)
(Statistics Toolbox)
1.1.2 MATLAB
1
(1)
MATLAB
MATLAB
(2)
MATLAB
(3)
MATLABNotebookWordMATLAB
2
3
4
5. Simulink
MATLABSimulinkSimulink
1.2 MATLAB 6.5
MATLAB6.5MATLAB(MATLABDesktop)1.1
MATLABMATLAB6.5Start
1.2.1
MATLABFileEditViewWebWindowHelp
1File
1.1 File
New
M-file
MM/
Figure
Model
GUI
(GUI)
Open...
Close Command History
Import Data...
Save Workspace as...
MAT
Page Setup...
Set Path...
Preferences...
MATLAB
Print...
Print Selection...
Exit MATLAB
MATLAB
2Edit
Edit1.3EditWindowsEdit
Paste SpecialImport WizardMATLAB
3View
4.48
1.2 View
Desktop Layout
()
Undock Command Window
Command Window
Command History
Current Directory
Workspace
Launch Pad
Profiler
Help
4. Web
1.3 Web
The MathWorks Web Site
MathWorks
MATLAB Central
MATLAB Central
MATLAB File Exchange
MATLAB File Exchange
MATLAB Newsgroup Access
MATLAB Newsgroup Access
Check for Updates
Products
Membership
MathWorks
Technical Support Knowledge Base
MathWorks
5. Windows
Windows
6. Help
Help
7.
Desktop ToolsWebPreferencesHelpDemos
1.2.2
1.2.3
1. (Command Window)
MATLAB
ViewUndock Command Window
MATLABViewDock Command Window
(1)
>>
iffor
1.1
>> a=12.7
a =
12.7000
>> b='Hello'
b =
Hello
>> if a>0 c=5 ,end
c =
5
(2)
MATLAB1.4
1.4
Home
End
Delete
Backspace
PageUp
Esc
Page Down
CTRL+C
MATLAB
(3)
1.5MATLAB
,
.
;
:
%
( )
[ ]
{ }
-
At
@
MATLAB
1.2
>> a=12.5,b='Hello' %,,
a =
12.5000
b =
Hello
>>c=[1 2;3 4;5 6]
% [ ],,
c =
1 2
3 4
5 6
>> d=a*...
%...
(4)
4(Short)
File Preferences1.10
1
1.2
1.4
1.6
1.8
2
2.2
2.4
2.6
2.8
3
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
format
format
1.6Format
format
format short()
10005
314.159314.1590
3141.593.1416e+003
format short e
5
3.1416e+000
format short g
format shortformat short e
3.1416
format long
15
3.14159265358979
format long e
15
3.141592653589793e+000
format long g
format longformat long e
3.1415926358979
format rat
355/113
format hex
400921fb54442dl8
format +
+
format bank
()
3.14
format compact
format loose
(5)
clc
more
2. (Command History)
1.7
(Copy)
Copy
(Evaluate Selection)
Evaluate Selection
M(Create M-File)
Create M-FileM/
1.11
3. (Current Directory Browser)
(1)
WindowsMATLABmatlab/work
MATLABmatlab/bin/win32matlab.exematlab/bin/win32
MATLAB
cd
%
cd
%
cd ..
%
(2)
1.8
M(Run)
Run M
M(Open)
MOpenMM/
M
MAT(Open)
MATOpen
MAT
MAT(Import Data)
MATImport DataImport WizardFinish
(3) MMAT
MMAT
FilepreferencesPreferencesCurrent DirectoryBrower Display OptionsShow M-file Comments and MAT-file CommentsOK
4. (Workspace Browser)
MATLAB
a=12.5
b='Hello'
c=[1 2;3 4;5 6]
1.14
(1)
1.9
OpenArray Editor
Graph
MAT
Save Workspace As
MAT
Save Selection As
DeleteConfirm DeleteYes
EditDelete
Clear Workspace
(2)
save: MAT
save FileName 1 2
%
FileNameMAT
12
-ASCII-append
>> save FileName1
%FileName1.mat
>> save FileName2 a b
%abFileName2.mat
>> save FileName3 a b -append %abFileName3.mat
load:
load FileName 1 2
12
>> load Filename1
%FileName1.mat
>> load FileName2 a b
%FileName2.matab
who: MATLAB
>> who
Your variables are:
a b c
whos: MATLAB
>> whos
Name Size Bytes Class
a 1x1 8 double array
b 1x5 10 char array
c 3x2 48 double array
Grand total is 12 elements using 66 bytes
clear:
>> clear a
>> who
Your variables are:
b c
exist(X) :
i=exist(X)
%X
i=1 X
i=2 X.m
i=3 X.mex
i=4 X.mdl
i=5 X
i=0
5. (Array Editor)
Open
1.15c=[1 2;3 4;5 6]Array Editor
Numeric format
Sizeby
6. (Launch Pad)
Import WizardProfilerGUIDE
Help
DemosDemos
Product Page(Web)
7. M(EditorDebugger)
M
MATLABFileNewM-fileM
MATLABFileOpenOpenM
M(.m)M
1.17Ex0101.mM
8. (Help NavigatorBrowser)
ViewHelpHelpMATLAB Help
9. (Profiler)
ViewProfilerprofile viewer1.18
ViewDock profilerMATLAB
1.3 MATLAB 6.5
MATLAB6.5MATLAB
1.
1.19
1.19Help Navigator()Help Browser()
(1) Contents
Begin HereMATLAB
Release Notes For Release R13
Installation
MATLAB
Getting StartedMATLAB
Examples
Development EnvironmentMATLAB
Mathematics MATLAB
Programming and Data TypesM
Graphics
Printable DocumentationPDF
(2) Index
IndexMATLAB
(3) Search
Search
(4) Demos
DemosMATLABDemo
(5) Favorites
Favorites()
2.
help MATLAB
help topic %
lookfor
lookfor topic
% MH1()
lookfor topic all %M
helpwin(1.19)
helpwin topic
%
3. PDF
MATLAB 6.5PDFPDF..\matlab\help\pdf-docAdobe Acrobat Reader
4.
(1) Demos
DemosMATLAB
(2) Web
MathWorksMATLABMATLABMATLAB
1.4 MATLAB 6.5
1.4.1 MATLAB
1.
M.mMMMATLABM
2.
MAT.matsave
3.
MEX.mexMATLABMM(8.1)
4.
.figFileMATLAB
5.
.mdlSimulink.s
1.4.2
1. MATLAB
MATLAB
MATLABX
XMATLAB(Built-in Function)
X.mX.mex
MATLABX.m X.mex
MATLAB
existwhichloadMATLAB
2. MATLAB
(1)
MATLABFileSet Path
pathtool
Add FolderAdd with Subfolders
(2) path
path (path, ) %MATLAB
>> path(path,'c: :\MyDir ')
1.4.3
what MMATMEX
>> what
M-files in the current directory D:\MATLAB6p1\toolbox\matlab\elfun
Contents asech cosh isreal sec
abs asin cot log sech
acos asinh coth log10 sign
acosh atan cplxpair log2 sin
acot atan2 csc mod sinh
acoth atanh csch nextpow2 sqrt
acsc ceil exp pow2 tan
acsch complex fix real tanh
angle conj floor rem unwrap
asec cos imag round
MEX-files in the current directory D:\MATLAB6p1\toolbox\matlab\elfun
complex
dir
dir %
>> dir
. asinh.m cplxpair.m pow2.m
.. atan.m csc.m real.m
Contents.m atan2.m csch.m rem.m
abs.m atanh.m exp.m round.m
acos.m ceil.m fix.m sec.m
acosh.m complex.c floor.m sech.m
acot.m complex.csf imag.m sign.m
acoth.m complex.dll isreal.m sin.m
acsc.m complex.m ja sinh.m
acsch.m conj.m log.m sqrt.m
angle.m cos.m log10.m tan.m
asec.m cosh.m log2.m tanh.m
asech.m cot.m mod.m unwrap.m
asin.m coth.m nextpow2.m
type M
>> type abs.m
%ABS Absolute value.
% ABS(X) is the absolute value of the elements of X. When
% X is complex, ABS(X) is the complex modulus (magnitude) of
% the elements of X.
%
% See also SIGN, ANGLE, UNWRAP.
% Copyright 1984-2001 The MathWorks, Inc.
% $Revision: 5.8 $ $Date: 2001/04/15 12:02:51 $
% Built-in function.
which MMEXSimulink
>> which abs.m
D:\MATLAB6p1\toolbox\matlab\elfun\abs.m
matlabroot MATLAB
>> matlabroot
ans =
D:\MATLAB6p1
diary()
diary ('file')
%
diary off
%diary
diary on
%diary
1.4.4 MATLAB
MATLAB
MATLABexit
MATLABquit
MATLAB
1.5
1.3MATLAB
MATLAB
(Command Window)
a=[1 2 3; 4 5 6;7 8 9];
b=[1 1 1;2 2 2;3 3 3 ];
c='';
d=a+b*i
(Workspace Browser)
d(Array Editor)1.23
(Command History)1.24Create M-FileM
M(EditorDebugger)1.25Savec:\MyDir\Ex0103.m
(Current Directory Browser)c:\MyDirEx0103.mEx0103
save Ex0103Ex0103.mat1.26
exitMATLAB
MATLABEx0103MATLAB
MATLABFileSet Pathc:\MyDirEx0103
Ex0103.matFileImport Datac:\MyDir\ Ex0103.mat
>> type Ex0103
a=[1 2 3; 4 5 6;7 8 9];
b=[1 1 1;2 2 2;3 3 3 ];
c='';
d=a+b*i
2 MATLAB
MATLAB
2.1
2.1.1
(uint8uint16uint32uint64)(int8int16int32int64)
2.1.2
1.
10-30910309
-25.672.56e-56(2.5610-56)4.68e204(4.6810204)
2.
MATLAB
11
1nn1
00([])
n
3.
MATLABij
z=a+b*iz=a+b*j
z=a+biz=a+bj(b)
z=r*exp(i*theta)
a=real(z)
%
b=imag(z)
%
r=abs(z)
%
theta=angle(z) %
za=r*cos()
zb=r*sin()
z
2
2
b
a
r
+
=
ztheta=arctg(b/a)
a=1-2*i
a =
1.0000 - 2.0000i
real(a)
ans =
1
imag(a)
ans =
-2
abs(a)
ans =
2.2361
angle(a)*180/pi
%
ans =
-63.4349
2.1.3
1.
aA
6363MATLAB6.531
(%)6ABCAB%C
(ifwhile)
2.
MATLABMATLAB
2.1
ans
pi
eps
flops
inf
1/0
NaNnan
0/0/0
i j
i=j=
nargin
nargout
realmin
realmax
MATLABans
2*pi
ans =
6.2832
2.2
MATLAB
2.2.1
(1) ([])
(2)
(3)
(4)
1.
c=[1 2;3 4;5 3*2] % [ ],,
c =
1 2
3 4
5 6
:
c=[1 2
3 4
5 6]
1 2
3 4
5 6
2.
(1) from:step:to
from:to
from:step:to
fromstepto
stepstep=1
stepstep>0from>tostep vertcat
All rows in the bracketed expression must have the same
number of columns.
str5=[str1;str3,' ']
%str3
str5 =
Hello
!
(3) str2matstrvcatchar
str2matstrvcatchar
str6=str2mat(str1,str2,str3)
str6 =
Hello
I like 'MATLAB'
!
str7=char(str1,str2,str3)
str7 =
Hello
I like 'MATLAB'
!
str8=strvcat(str1,str2)
str8 =
Hello
I like 'MATLAB'
whos
Name Size Bytes Class
str1 1x5 10 char array
str2 1x15 30 char array
str3 1x3 6 char array
str4 1x22 44 char array
str5 2x5 20 char array
str6 3x15 90 char array
str7 3x15 90 char array
str8 2x15 60 char array
Grand total is 186 elements using 350 bytes
5.
evalMATLAB
str9='a=2*5'
str9 =
a=2*5
eval(str9)
%
a =
10
6.
disp(;)
disp('2*2a')
2*2a
disp(str1)
Hello
2.2.4
1.
a =
1 2 3
4 5 6
7 8 9
2.4
det(X)
det(a)
ans =
0
rank(X)
rank(a)
ans =
2
inv(X)
Xdet(X)X-1X X-1
inv(a )
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 1.541976e-018.
ans =
1.0e+016 *
-0.4504 0.9007 -0.4504
0.9007 -1.8014 0.9007
-0.4504 0.9007 -0.4504
[v,d]=eig(X)
Xv=vdvd
[v,d]=eig(a)
v =
-0.2320 -0.7858 0.4082
-0.5253 -0.0868 -0.8165
-0.8187 0.6123 0.4082
d =
16.1168 0 0
0 -1.1168 0
0 0 -0.0000
diag(X)
X
diag(a)
ans =
1
5
9
[l,u]=lu(X)
l
[l,u]=lu(a)
l =
0.1429 1.0000 0
0.5714 0.5000 1.0000
1.0000 0 0
u =
7.0000 8.0000 9.0000
0 0.8571 1.7143
0 0 0.0000
[q,r]=qr(X)
mnXqXrqXnm1
[q,r]=qr(a)
q =
-0.1231 0.9045 0.4082
-0.4924 0.3015 -0.8165
-0.8616 -0.3015 0.4082
r =
-8.1240 -9.6011 -11.0782
0 0.9045 1.8091
0 0 -0.0000
[u,s,v]=svd(X)
mnXu,vnnmmsmnXnm
[u,s,v]=svd(a)
u =
-0.2148 0.8872 0.4082
-0.5206 0.2496 -0.8165
-0.8263 -0.3879 0.4082
s =
16.8481 0 0
0 1.0684 0
0 0 0.0000
v =
-0.4797 -0.7767 -0.4082
-0.5724 -0.0757 0.8165
-0.6651 0.6253 -0.4082
det(a)=0det(a)inv(a)(cond) MATLAB
a=[1 2 3;4 5 6;7 8 9]
a =
1 2 3
4 5 6
7 8 9
inv(a)
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 1.541976e-018.
ans =
1.0e+016 *
-0.4504 0.9007 -0.4504
0.9007 -1.8014 0.9007
-0.4504 0.9007 -0.4504
2.
(1)
AB
AB
(2) *
AB
.*ABAB
x1=[1 2;3 4;5 6];
x2=eye(3,2)
x2 =
1 0
0 1
0 0
x1+x2
%
ans =
2 2
3 5
5 6
x1.*x2
%
ans =
1 0
0 4
0 0
x1*x2
%x1x2
??? Error using ==> *
Inner matrix dimensions must agree.
x3=eye(2,3)
x3 =
1 0 0
0 1 0
x1*x3
%
ans =
1 2 0
3 4 0
5 6 0
(3)
\/
A\B=A-1*B
A/B=A*B-1
A-1inv(A)
A.\BA./B
AB
2.12
=
+
-
=
-
+
=
+
-
9
x
x
4x
5
5x
x
3x
5
3x
x
2x
3
2
1
3
2
1
3
2
1
AX=B
-
-
-
=
1
1
4
5
1
3
3
1
2
A
=
9
5
5
B
A=[2 -1 3;3 1 -5;4 -1 1]
A =
2 -1 3
3 1 -5
4 -1 1
B=[5;5;9]
B =
5
5
9
X=A\B
X =
2
-1
0
A*X=BmnAmn
n=mAA\Binv(A)*B
m > nX=inv(A*A)*(A*B)
m < Xn-mX=inv(A*A)*(A*B)
(4)
A^BA
A
BAB
BA|B|
B
BAA=W*D/WDA^B=W*D^B/W
A
BAA=W*D/WDA^B=W*diag(D.^B)/W
A.^B
ABA(i,j)B
ABABA(i,j)B(i,j)
ABA^ B(i,j)ij
2.13
x1=[1 2;3 4];
x2=eye(2)
x2 =
1 0
0 1
x1/x2
%
ans =
1 2
3 4
inv(x1)
%
ans =
-2.0000 1.0000
1.5000 -0.5000
x1\x2
%
ans =
-2.0000 1.0000
1.5000 -0.5000
x1./x2
%
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
ans =
1 Inf
Inf 4
x1.\x2
%
ans =
1.0000 0
0 0.2500
x1^2
%
ans =
7 10
15 22
x1^-1
%-1inv
ans =
-2.0000 1.0000
1.5000 -0.5000
x1^0.2
%
ans =
0.8397 + 0.3672i 0.2562 - 0.1679i
0.3842 - 0.2519i 1.2239 + 0.1152i
2^x1
%
ans =
10.4827 14.1519
21.2278 31.7106
2.^x1
%
ans =
2 4
8 16
x1.^x2
%
ans =
1 1
1 4
3.
AAA
A.AA
2.14
x1=[1 2;3 4];
x2=eye(2);
x3=x1+x2*i
x3 =
1.0000 + 1.0000i 2.0000
3.0000 4.0000 + 1.0000i
x3'
%
ans =
1.0000 - 1.0000i 3.0000
2.0000 4.0000 - 1.0000i
x3.'
%
ans =
1.0000 + 1.0000i 3.0000
2.0000 4.0000 + 1.0000i
4.
MATLAB2.5
2.5
abs
rat
sqrt
mod
real
round
45
imag
fix
0
conj
floor
-
sin
ceil
-
cos
sign
tan
rem
asin
exp
acos
log
atan
log10
10
atan2
pow2
2
sinh
bessel
cosh
gamma
tanh
2.15
t=linspace(0,2*pi,6)
t =
0 1.2566 2.5133 3.7699 5.0265 6.2832
y=sin(t)
%
y =
0 0.9511 0.5878 -0.5878 -0.9511 -0.0000
y1=abs(y)
%
y1 =
0 0.9511 0.5878 0.5878 0.9511 0.0000
1-exp(-t).*y
%
ans =
1.0000 0.7293 0.9524 1.0136 1.0062 1.0000
SAB
2.6
A+B
A+B
A-B
A-B
S.*B
SB
S*B
A.*B
A*B
S./B
SB
S\B
BS
A./B
AB
A/B
ABAB
B.\A
B\A
AB()
A.^S
AS
A^S
AS
A.^S
SA
A^S
SA
S.^B
B
S^B
BS
A.
conj(A)
A
exp(A)
eA
expm(A)
A
log(A)
A
logm(A)
A
sqrt(A)
A
sqrtm(A)
A
f(A)
A
funm(A,FUN)
funm(A,FUN)AFUN
5.
(1)
= = =() ~=()
(1)(0)
01
01
=
= = ~=
(2)
&()|()~()xor()
&&()1()
|| ()1()1()
0(1)0(0)012.7
2.7
a
b
a & b
a | b
~a
xor(a,b)
0
0
0
0
1
0
0
1
0
1
1
1
1
0
0
1
0
1
1
1
1
1
0
0
01
a=0;b=5; c=10;
(a~=0)&&(b> a=sym('sin(2)')
a =
sin(2)
sym
sym(,)
%
dfer 3.1
3.1
d
(32)
f
r
()p/qp*q10^qpi/q2^qsqrt(p)
e
a=sym('sin(2)')
a =
sin(2)
a=sym(sin(2))
a =
8190223105242182*2^(-53)
3.1
a1=2*sqrt(5)+pi
%
a1 =
7.6137
a2=sym('2*sqrt(5)+pi')
%
a2 =
2*sqrt(5)+pi
a3=sym(2*sqrt(5)+pi)
%
a3 =
8572296331135796*2^(-50)
a4=sym(2*sqrt(5)+pi,'d')
%
a4 =
7.6137286085893727261009189533070
a31=a3-a1
%
a31 =
0
a5='2*sqrt(5)+pi'
%
a5 =
2*sqrt(5)+pi
3.1
3.1.2
symsyms
1. sym
sym(,)
%
positiverealunreal positive realunreal
3.2
syms x y real
%
z=x+i*y;
%z
real(z)
%zx
ans =
x
sym('x','unreal');
%
real(z)
%z
ans =
1/2*x+1/2*conj(x)
xyz
sym()
%
3.2
f1=sym('a*x^2+b*x+c')
f1 =
a*x^2+b*x+c
2.syms
syms(arg1, arg2, ,)
%
syms arg1 arg2 ,
%
symssym
3.2syms
syms a b c x
%
f2=a*x^2+b*x+c
%
f2 =
a*x^2+b*x+c
syms('a','b','c','x')
f3=a*x^2+b*x+c;
%
abcxf2f3f1
3.1.3
symsyms
A=sym('[a,b;c,d]')
A =
[ a, b]
[ c, d]
syms
syms a b c d
A=[a b;c d]
A =
[ a, b]
[ c, d]
3.3
A=sym('[a,b;c,d]')
%
A =
[ a, b]
[ c, d]
B='[a,b;c,d]'
%
B =
[a,b;c,d]
C=[a,b;c,d]
%
??? Undefined function or variable 'a'.
abcdMATLAB
C=sym(B)
%
C =
[ a, b]
[ c, d]
whos
Name Size Bytes Class
A 2x2 312 sym object
B 1x9 18 char array
C 2x2 312 sym object
Grand total is 25 elements using 642 bytes
A22
3.2
8
3.2.1
1.
(1)
*\/^
.*./.\.^
.
(2)
= =~=10
2.
(1)
sincostansinhcoshtanhatan2asinacosatan
(2)
sqrtexpexpmlog(ln)log2log10
(3)
conjrealimagabsMATLAB
(4)
MATLABdiagtriutrilinvdetrank polyexpmeig
3.4
=
22
21
12
11
a
a
a
a
A
syms a11 a12 a21 a22
A=[a11 a12;a21 a22]
%
A =
[ a11, a12]
[ a21, a22]
det(A)
%
ans =
a11*a22-a12*a21
A.'
%
ans =
[ a11, a21]
[ a12, a22]
eig(A)
%
ans =
[ 1/2*a11+1/2*a22+1/2*(a11^2-2*a11*a22+a22^2+4*a12*a21)^(1/2)]
[ 1/2*a11+1/2*a22-1/2*(a11^2-2*a11*a22+a22^2+4*a12*a21)^(1/2)]
3.5f=2x2+3x+4g=5x+6
f=sym('2*x^2+3*x+4')
f =
2*x^2+3*x+4
g=sym('5*x+6')
g =
5*x+6
f+g
%
ans =
2*x^2+8*x+10
f*g
%
ans =
(2*x^2+3*x+4)*(5*x+6)
3.2.2
1. Symbolic Math Toolbox
Symbolic Math Toolbox
MATLAB
Maple
VPAMaple
2.
VPAdigitsvpa
digits(n)
%
ndigitsMapledigits32
S=vpa(s,n)
%sn
sSndigitsvpasdigits
3.6
5
2
+
a=sym('2*sqrt(5)+pi')
a =
2*sqrt(5)+pi
digits
%
Digits = 32
vpa(a)
%
ans =
7.6137286085893726312809907207421
vpa(a,20)
%
ans =
7.6137286085893726313
digits(15)
%
vpa(a)
%digits
ans =
7.61372860858937
3. Symbolic Math Toolbox
3.62/3
a1 =2/3
%
a1 =
0.6667
a2 = sym(2/3) %
a2 =
2/3
a3 =vpa('2/3',32) %VPA
a3 =
.66666666666666666666666666666667
VPA
a1formatformat
format long
a1
a1 =
0.66666666666667
3.2.3
1.
symvpaVPA
2.
double numericVPA
N=double(S)
%SN
N=numeric(S)
%SN
3.7
5
2
+
clear
a1=sym('2*sqrt(5)+pi')
a1 =
2*sqrt(5)+pi
b1=double(a1)
%
b1 =
7.6137
a2=vpa(sym('2*sqrt(5)+pi'),32)
a2 =
7.6137286085893726312809907207421
b2=numeric(a2)
%
b2 =
7.6137
3.7
b3=eval(a1)
b3 =
7.6137
whosb1b2b3
whos
Name Size Bytes Class
a1 1x1 148 sym object
a2 1x1 190 sym object
b1 1x1 8 double array
b2 1x1 8 double array
b3 1x1 8 double array
Grand total is 50 elements using 362 bytes
3.3
3.3.1
1.
MATLAB
ij
xxxxx
2. findsym
findsym
findsym(EXPR,n)
%
EXPRnnEXPR
3.8
f=sym('a*x^2+b*x+c')
f =
a*x^2+b*x+c
findsym(f)
%
ans =
a, b, c, x
g=sym('sin(z)+cos(v)')
g =
sin(z)+cos(v)
findsym(g,1)
%
ans =
z
zvxxz
3.3.2
f(x)
f(x)=x3+6x2+11x-6
f(x)=(x-1)(x-2)(x-3)
f(x)=x(x(x-6)+11)-6
3.9
f=sym('x^3-6*x^2+11*x-6')
%
f =
x^3-6*x^2+11*x-6
g= sym('(x-1)*(x-2)*(x-3)')
%
g =
(x-1)*(x-2)*(x-3)
h= sym(' x*(x*(x-6)+11)-6')
%
h =
x*(x*(x-6)+11)-6
1. pretty
3.9
pretty(f)
3 2
x - 6 x + 11 x - 6
2. collect
3.9
collect(g)
ans =
x^3-6*x^2+11*x-6
xy
f1=sym('x^3+2*x^2*y+4*x*y+6')
f1 =
x^3+2*x^2*y+4*x*y+6
collect(f1,'y')
%y
ans =
(2*x^2+4*x)*y+x^3+6
3. expand
3.9
expand(g)
ans =
x^3-6*x^2+11*x-6
4. horner
3.9
horner(f)
ans =
x*(x*(x-6)+11)-6
5. factor
3.9
factor(f)
ans =
(x-1)*(x-2)*(x-3)
6. simplify
3.9cos2x-sin2x
y=sym('cos(x)^2-sin(x)^2')
y =
cos(x)^2-sin(x)^2
simplify(y)
ans =
2*cos(x)^2-1
7. simple
simple pretty collectexpandfactorsimplifyradsimpcombinecombine(trig)convert
3.9simplecos2x-sin2x
simple(y)
simplify:
2*cos(x)^2-1
radsimp:
cos(x)^2-sin(x)^2
combine(trig):
cos(2*x)
factor:
(cos(x)-sin(x))*(cos(x)+sin(x))
expand:
cos(x)^2-sin(x)^2
combine:
cos(2*x)
convert(exp):
(1/2*exp(i*x)+1/2/exp(i*x))^2+1/4*(exp(i*x)-1/exp(i*x))^2
convert(sincos):
cos(x)^2-sin(x)^2
convert(tan):
(1-tan(1/2*x)^2)^2/(1+tan(1/2*x)^2)^2-4*tan(1/2*x)^2/(1+tan(1/2*x)^2)^2
collect(x):
cos(x)^2-sin(x)^2
ans =
cos(2*x)
cos(2*x)
3.3.3
1. subexpr
subexpr(s,s1)
%s1s
subexpr
3.10subexpr
d
c
b
a
syms a b c d x
s=eig([a b;c d])
%
s =
[ 1/2*a+1/2*d+1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2)]
[ 1/2*a+1/2*d-1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2)]
subexpr(s,x)
%x
ans =
[ 1/2*a+1/2*d+1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2)]
[ 1/2*a+1/2*d-1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2)]
2. subs
subs
subs(s)
%s
subs(s,new)
%news
subs(s,old,new)
%newsold
3.10subs(x+y)2+3(x+y)+5
f=sym('(x+y)^2+3*(x+y)+5') %
f =
(x+y)^2+3*(x+y)+5
x=5;
f1=subs(f)
%x
f1 =
(5+y)^2+20+3*y
f2=subs(f,'x+y','s')
%sx+y
f2 =
((s))^2+3*((s))+5
f3=subs(f,'x+y',5)
%5x+y
f3 =
45
f4=subs(f,'x','z')
%zx
f4 =
((z)+y)^2+3*((z)+y)+5
3.3.4
MATLABfinverse
finverse(f,v)
%vf(v)
v
1.
3.11tex
f=sym('t*e^x')
%
f =
t*e^x
g=finverse(f)
%
g =
log(x/t)/log(e)
g=finverse(f,'t')
%t
g =
t/(e^x)
t't'
syms t
g=finverse(f,t)
2.
3.11texay2+by+c
f=sym('t*e^x');
%
g=sym('a*y^2+b*y+c'); %
h1=compose(f,g)
%f(g(x))
h1 =
t*e^(a*y^2+b*y+c)
h2=compose(g,f)
%g(f(x))
h2 =
a*t^2*(e^x)^2+b*t*e^x+c
h3=compose(f,g,'z')
%f(g(z))
h3 =
t*e^(a*z^2+b*z+c)
3.11texy2
f1=sym('t*e^x');
g1=sym('y^2');
h1=compose(f1,g1)
h1 =
t*e^(y^2)
h2=compose(f1,g1,'z') %f(g(z))
h2 =
t*e^(z^2)
h3=compose(f1,g1,'t','y') %tf(g(z))
h3 =
y^2*e^x
h4=compose(f1,g1,'t','y','z') %tf(g(z))zy
h4 =
z^2*e^x
h5=subs(h3,'y','z')
%h5h4
h5 =
(z)^2*e^x
3.3.5
1.
f(x)MATLABsym2polypoly2sym
(1) sym2poly
3.122x+3x2+1
f=sym('2*x+3*x^2+1')
f =
2*x+3*x^2+1
sym2poly(f)
%
ans =
3 2 1
f1=sym('a*x^2+b*x+c')
f1 =
a*x^2+b*x+c
sym2poly(f1)
??? Error using ==> sym/sym2poly
Input has more than one symbolic variable.
(2) poly2sym
3.12
g=poly2sym([1 3 2])
%x
g =
x^2+3*x+2
g=poly2sym([1 3 2],sym('y')) %y
g =
y^2+3*y+2
2.
()numden
[n,d]=numden(f)
ndf
3.13numden
2
3s
s
1
2
+
+
2
3s
s
1
2
+
+
f1=sym('1/(s^2+3*s+2)')
f1 =
1/(s^2+3*s+2)
f2=sym('1/s^2+3*s+2')
f2 =
1/s^2+3*s+2
[n1,d1]=numden(f1)
n1 =
1
d1 =
s^2+3*s+2
[n2,d2]=numden(f2)
n2 =
1+3*s^3+2*s^2
d2 =
s^2
3.4
3.4.1
Symbolic Math Toolboxlimitlimit3.2
3.2 limit
f(x)
lim
0
x
limt(f)
x0
f(x)
lim
a
x
limt(f,x,a)
xa
f(x)
lim
a
x
-
limt(f,x,a, left)
xa
f(x)
lim
a
x
+
limt(f,x,a, right)
xa
3.141/x0
f=sym('1/x')
f =
1/x
limit(f)
%x0
ans =
NaN
limit(f,'x',0)
%x0
ans =
NaN
limit(f,'x',0,'left') %0
ans =
-inf
limit(f,'x',0,'right') %0
ans =
inf
NaN
t
f(x)
t)
f(x
lim
(x)
f'
0
t
-
+
=
3.14cos(x)
syms t x
limit((cos(x+t)-cos(x))/t,t,0)
ans =
-sin(x)
3.4.2
diff
diff(f)
%f
diff(f,t)
%ft
diff(f,n)
%fn
diff(f,t,n) %ftn
3.15f(x)ax2+bx+cf(x)
f=sym('a*x^2+b*x+c')
f =
a*x^2+b*x+c
diff(f) %x
ans =
2*a*x+b
diff(f,'a') %a
ans =
x^2
diff(f,'x',2) %x
ans =
2*a
diff(f,3) %x
ans =
0
diff
3.15
x
2
e
tsin(x)
t
2x
syms t x
g=[2*x t^2;t*sin(x) exp(x)] %
g =
[ 2*x, t^2]
[ t*sin(x), exp(x)]
diff(g)
%x
ans =
[ 2, 0]
[ t*cos(x), exp(x)]
diff(g,'t')
%t
ans =
[ 0, 2*t]
[ sin(x), 0]
diff(g,2)
%x
ans =
[ 0, 0]
[ -t*sin(x), exp(x)]
diff
3.15diff
x1=0:0.5:2;
y1=sin(x1)
y1 =
0 0.4794 0.8415 0.9975 0.9093
diff(y1)
%
ans =
0.4794 0.3620 0.1560 -0.0882
3.4.3
int
int(f,t)
%t
int(f,t,a,b)
%t
int(f,t,m,n) %t
ttab[a,b]mn[m,n]MATLABMATLAB
3.16
cos(x)
cos(x)
f=sym('cos(x)');
int(f)
%
ans =
sin(x)
int(f,0,pi/3) %
ans =
1/2*3^(1/2)
int(f,'a','b') %
ans =
sin(b)-sin(a)
int(int(f))
%
ans =
-cos(x)
diffintf
f='cos(x)';
3.16
x
2
e
tsin(x)
t
2x
syms t x
g=[2*x t^2;t*sin(x) exp(x)] %
g =
[ 2*x, t^2]
[ t*sin(x), exp(x)]
int(g)
%x
ans =
[ x^2, t^2*x]
[ -t*cos(x), exp(x)]
int(g,'t')
%t
ans =
[ 2*x*t, 1/3*t^3]
[ 1/2*t^2*sin(x), exp(x)*t]
int(g,sym('a'),sym('b')) %x
ans =
[ b^2-a^2, t^2*(b-a)]
[ -t*cos(b)+t*cos(a), exp(b)-exp(a)]
3.4.4
1. symsum
symsum(s,x,a,b)
%s
xxs[a,b]x
3.17
K
K
+
+
+
+
+
2
2
2
k
1
3
1
2
1
1
1+x+x2++xk+
syms x k
s1=symsum(1/k^2,1,10)
%10
s1 =
1968329/1270080
s2=symsum(1/k^2,1,inf)
%
s2 =
1/6*pi^2
s3=symsum(x^k,'k',0,inf)
%k
s3 =
-1/(x-1)
2. taylor
taylor (F,x,n)
%
xFFnn5
3.17ex
K
K
+
+
+
+
+
+
-
1
k
3
2
x
k!
1
x
3
2
1
x
2
1
x
1
syms x
s1=taylor(exp(x),8)
%8
s1 =
1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7
s2=taylor(exp(x))
%5
s2 =
1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5
3.5
3.5.1(Fourier)
fourierintfourierifourier
1. fourier
Ffourier(f,t ,w)
%f(t)fourierF
Fwwwfttx
2. fourier
f=ifourier (F)
%Ffourierf(t)
f=ifourier (F,w,t)
ifourierfourier
3.18f(t)=
t
1
fourierFFfourier
syms t w
F=fourier(1/t,t,w)
%fourier
F =
i*pi*(Heaviside(-w)-Heaviside(w))
f=ifourier(F,t)
%fourier
f =
1/t
f=ifourier(F)
%fourierx
f =
1/x
Heaviside(t)
0
t
0
t
0
1
p/p
p/p
p/p
p/p
Heaviside/pp class="cY"3.18fourier/pp fourier(sym('Heaviside(t)')) /ppans =/pppi*Dirac(w)-i/w /pp class="cY"Dirac/pp class="cY"3.5.2(Laplace)/pp class="cY"1. Laplace/pp class="cY"/pp class="cY"
F=laplace(f,t,s)
%fLaplaceF/pp class="cY"FssF's'ftt't'/pp class="cY"3.19sin(at)Laplace/pp class="cY" syms a t s/pp F1=laplace(sin(a*t),t,s)
%sinatLaplace /ppF1 =/ppa/(s^2+a^2) /pp F2=laplace(sym('Heaviside(t)')) %Laplace /ppF2 =/pp1/s /pp class="cY"2. Laplace/pp class="cY"/pp class="cY"
filaplace(F,s,t)
%FLaplacef/pp class="cY"3.19div class="embedded" id="_1130047378"/pa/p
ps/p
p1/p
p+/p
1Laplace/pp class="cY" syms s a t/pp f1=ilaplace(1/(s+a),s,t) %1/s+aLaplace /ppf1 =/ppexp(-a*t) /pp f2=ilaplace(1,s,t)
%1Laplace /ppf2 =/ppDirac(t) /pp class="cY"3.5.3 Z/pp class="cY"1. ztrans/pp class="cY"/pp class="cY"
Fztrans(f,n, z)
%fZF/pp class="cY"Fzn'n'z'z'/pp class="cY"3.20e-atZ/pp class="cY" syms a n z t/pp Fz1=ztrans(sym('Heaviside(t)'),n,z) %Z /ppFz1 =/ppHeaviside(t)*z/(z-1) /pp Fz2=ztrans(sym('Dirac(t)'),n,z)
%Z /ppFz2 =/ppDirac(t)*z/(z-1) /pp Fz3=ztrans(exp(-a*t),n,z)
%e-atZ /ppFz3 =/ppexp(-a*t)*z/(z-1) /pp class="cY"2. iztrans/pp class="cY"/pp class="cY"
fiztrans(F,z,n)
%Fzf/pp class="cY"3.20Ze-atZ/pp class="cY" syms n z t/pp f1=iztrans(Fz1,z,n) /ppf1 =/ppHeaviside(t) /pp f2=iztrans(Fz2,z,n) /ppf2 =/ppDirac(t) /pp f3=iztrans(Fz3,z,n) /ppf3 =/pp class=""exp(-a*t) /pp class="cY"3.6/pp class="cY"3.6.1/pp class="cY"MATLABsolve/pp class="cY"/pp class="cY"
solve(eq,v)
%/pp class="cY"
solve(eq1, eq2,v1,v2,) % /pp class="cY"eqeq=0v/pp class="cY"3.21ax2+bx+c=0sinx=0/pp f1=sym('a*x^2+b*x+c')
% /ppf1 =/ppa*x^2+b*x+c /pp solve(f1)
%x /ppans =/pp[ 1/2/a*(-b+(b^2-4*a*c)^(1/2))]/pp[ 1/2/a*(-b-(b^2-4*a*c)^(1/2))] /pp f2=sym('sin(x)') /ppf2 =/ppsin(x) /pp solve(f2,'x') /ppans =/pp0 /pp class="cY"sinx=00/pp class="cY" 3.22div class="embedded" id="_1132993235"/p/p
p/p
p/p
p/p
p/p
p-/p
p=/p
p=/p
p+/p
p=/p
p+/p
p+/p
p1/p
pz/p
p*/p
py/p
p4/p
p3z/p
px/p
p0/p
p1/p
p2x/p
px/p
p2/p
/pp class="cY" eq1=sym('x^2+2*x+1');/pp class="cY" eq2=sym('x+3*z=4');/pp class="cY" eq3=sym('y*z=-1');/pp [x,y,z]=solve(eq1,eq2,eq3)
%x,y,z /ppx =/pp-1/ppy =/pp-3/5/ppz =/pp5/3 /pp class="cY"S=solve(eq1,eq2,eq3) /pp class=""S = /pp class="cY" x: [1x1 sym]/pp class="cY" y: [1x1 sym]/pp class="cY" z: [1x1 sym] /pp class="cY"3.6.2/pp class="cY"MATLABdsolve/pp class="cY"/pp class="cY"
dsolve(eq,con,v)
%/pp class="cY"
dsolve(eq1,eq2,con1,con2,v1,v2) %/pp class="cY"eqconvxt/pp class="cYdot" yeq/pp class=""ydiv class="embedded" id="_1133077192"/pdx/p
pdy/p
div class="embedded" id="_1133077219"/pdt/p
pdy/p
Dy/pp class=""yndiv class="embedded" id="_1133077227"/pn/p
pn/p
pdx/p
py/p
pd/p
div class="embedded" id="_1133077245"/pn/p
pn/p
pdt/p
py/p
pd/p
Dny/pp class="cYdot" 'con''y(a)=bDy(c)=d'C1C2/pp class="cY"3.23div class="embedded" id="_1132993232"/p2/p
p2/p
p2/p
px/p
pdx/p
pdy/p
p3/p
pdx/p
py/p
pd/p
px/p
p=/p
p-/p
y(1)=0y(0)=0/pp y=dsolve('x*D2y-3*Dy=x^2','x')
% /ppy =/pp-1/3*x^3+C1+C2*x^4 /pp y=dsolve('x*D2y-3*Dy=x^2','y(1)=0,y(5)=0','x') % /ppy =/pp-1/3*x^3+125/468+31/468*x^4 /pp class="cY"3.24div class="embedded" id="_1132993231"/px/p
pdt/p
pdy/p
py,/p
pdt/p
pdx/p
p-/p
p=/p
p=/p
/pp [x,y]=dsolve('Dx=y,Dy=-x') /ppx =/ppcos(t)*C1+sin(t)*C2/ppy =/pp-sin(t)*C1+cos(t)*C2 /pp class="cY"tC1C2/pp [x,y]=dsolve('Dx=y,Dy=-x','t') /pp class="cY"3.7 /pp class="cY"3.7.1/pp class="cY"1. ezplot ezplot3/pp class="cY"ezplotezplot3/pp class="cY"/pp class="cY"
ezplot(F,[xmin,xmax],fig)
%/pp class="cY"F[xmin,xmax][22]fig/pp class="cY"3.253.23y(x)3.2/pp y =sym('-1/3*x^3+1/3*x^4') /ppy =/pp-1/3*x^3+1/3*x^4 /pp ezplot(y) /pp class="" ezplot(y,[0,100])
%y[0,100] /pp/pp class="cY"3.26ezplot33.3/pp class="cY" x=sym('sin(t)');/pp class="cY" z=sym('t');/pp class="cY" y=sym('cos(t)');/pp ezplot3(x,y,z,[0,10*pi],'animate')
%t[0,10*pi] /pp class="cY"/pp class="cY"2. /pp class="cY"MATLAB3.3/pp class="cY"3.3 /pp class="cY"/pp class="cY"/pp class="cY"/p
p class="cY"ezcontour/pp class="cY"/pp class="cY"ezcontour('x*sin(t)',[-4,4])/p
p class="cY"ezcontourf/pp class="cY"/pp class="cY"ezcontourf('x*sin(t)',[-4,4])/p
p class="cY"ezmesh/pp class="cY"/pp class="cY"ezmesh('sin(x)*exp(-t)','cos(x)*exp(-t)','x',[0,2*pi])/p
p class="cY"ezmeshc/pp class="cY"/pp class="cY"ezmeshc('sin(x)*t',[-pi,pi])/p
p class="cY"ezpolar/pp class="cY"/pp class="cY"ezpolar('sin(t)',[0,pi/2])/p
p class="cY"ezsurf/pp class="cY"/pp class="cY"ezsurf('x*sin(t)','x*cos(t)','t',[0,10*pi])/p
p class="cY"ezsurfc/pp class="cY"/pp class="cY"ezsurfc('x*sin(t)','x*cos(t)','t',[0,pi,0,2*pi])/p
p class="cY"/pp class="cY"3.7.2/ppSymbolic Math Toolboxfuntool.mMATLABfuntool3.4/pp class="cY"/pp class="cY"3.8 Maple/pp class="cY"MATLABMapleMaple2000/pp class="cY"3.8.1Maple/pp class="cY"1. maple/pp class="cY"mapleMATLAB/pp class="cY"/pp class="cY"
maple(MapleStatement)
%MapleMapleStatement/pp class="cY"
maple(fun,arg1,arg2)
%arg1,arg2Maplefun/pp class="cY"3.27Maplediscrim/pp maple('discrim(a*x^2+b*x+c,x)') /ppans =/pp-4*a*c+b^2 /pp class="cY"/pp class="cY" syms a b c x/pp maple('discrim',a*x^2+b*x+c,'x') /ppans =/pp-4*a*c+b^2 /pp class="cY"MapleStatementMaplemhelpmaple/pp class="cY"2. mfun/pp class="cY"mfunMaple/pp class="cY"/pp class="cY"mfun('fun',p1,p2,)/pp class="cY"'fun'p1,p2,/pp class="cY"3.28gcd/pp mfun('gcd',20,30) /ppans =/pp 10 /pp class="cY"3.8.2 Maple/pp class="cY"1. mfunlist/pp class="cY"mfunlistmfunMaple/pp class="cY"2. mhelp/pp class="cY"mhelpMaple/pp class="cY"(1) mhelp indexMaple/pp class="cY"(2) mhelp index []Maplemhelp index3.4/pp class="cY"3.4 Maple/pp class="cY"/pp class="cY"/p
p class="cY"expression/pp class="cY"/p
p class="cY"function/pp class="cY"/p
p class="cY"3.28gcd/pp mhelp gcd /pp class="cY"4 MATLABGUI/pp class="cY"MATLAB/pp class="cY"4.1/pp class="cY"4.1.1plot/pp class="cY"1. plot(x) x/pp class="cY"plotMATLAB/pp class="cY"/pp class="cY"
plot(x)
%x/pp class="cY"
plot(x,y) %xy/pp class="cY"xy/pp class="cY"4.1plot(x)4.1/pp x1=[1 2 3] /ppx1 =/pp 1 2 3 /pp plot(x1) /pp x2=[0 1 0] /ppx2 =/pp 0 1 0 /pp plot(x2) /pp class="cY"2. plot(x,y) xy/pp class="cY"4.2y=sin(x)4.2/pp class="cY" x1=0:0.1:2*pi;/pp class="cY" y1=sin(x1);
%y1x1/pp class="" plot(x1,y1);/pp class="cY" x2=[0 1 1 2 2 3 ];/pp class="cY" y2=[1 1 0 0 1 1 ];/pp class="cY" plot(x2,y2);/pp axis([0 4 0 2])
%0-40-2 /pp class=""/pp class="cY"3. plot(x) x/pp class="cY"4.34.3/pp class="cY" x1=[1 2 3;4 5 6];/pp class="cY" plot(x1);/pp class="cY" x2=peaks;
%49*49/pp plot(x2); /pp class="cY"ax1bpeaks494949/pp class="cY"4. plot(x,y)/pp class=""plot(x,y)xy/pp class="cYdot" xyxyxyxyxyxyyxyxy/pp class="cYdot" xyyx/pp class="cYdot" xyxy/pp class="cY"4.44.4/pp class="cY" x1=[1 2 3];/pp y1=[1 2 3;4 5 6] /ppy1 =/pp 1 2 3/pp 4 5 6 /pp plot(x1,y1)
% /pp y2=[1 2 ;3 4; 5 6] /ppy2 =/pp 1 2/pp 3 4/pp class="" 5 6 /pp plot(x1,y2)
%/pp plot(y1,x1)/pp plot(y2,x1) /pp x2=[1 1 1;2 2 2] /pp/ppx2 =/pp 1 1 1/pp 2 2 2 /pp plot(x2,y1)
% /pp class="cY"5. plot(z)/pp class="cY"4.44.4(e)/pp z1=x2+i*y1 /ppz1 =/pp class="" 1.0000 + 1.0000i 1.0000 + 2.0000i 1.0000 + 3.0000i/pp 2.0000 + 4.0000i 2.0000 + 5.0000i 2.0000 + 6.0000i /pp plot(z1)
% /pp class="cY"6. plot(x1,y1,x2,y2,)/pp class="cY"plotMATLAB(xi,yi)/pp class="cY"4.54.5/pp class="cY" x=0:0.1:2*pi;/pp plot(x,sin(x),x,cos(x),x,sin(3*x)) % /pp class="cY"4.1.2/pp class="cY"4.1/pp class="cY"4.1/pp class="cY"/pp class="cY"/p
p class=""1/pp class="cY"/pp class="cY"/pp class="cY"/p
p class=""/pp class=""2 /pp class="cY"/pp class="cY"Figure No.1/pp class="cY"/p
p class=""3/pp class="cY"/pp class="cY"/p
p class=""4 /pp class="cY"/pp class="cY"/p
p class=""5 /pp class="cY"/pp class="cY"/p
p class=""6 /pp class="cY"()/p
p class=""7/pp class="cY"()()/p
p class=""8/pp class="cY"()/pp class="cY"/pp class="cY"/p
p class="cY"/pp class="cYdot" 13MATLAB/pp class="cYdot" 2/pp class="cYdot" 123/pp class="cY"4.1.3/pp class="cY"1. /pp class="cY"figure/pp class="cY"/pp class="cY"
figure(n)
%/pp class="cY"Figure No.n/pp class="cY"2. /pp class="cY"plotsubplot/pp class="cY"/pp class="cY"
subplot(m,n,k)
%(mn)k/pp class="cY"mnk,1/pp class="cY"4.6subplot4.6/pp class="cY" x=0:0.1:2*pi;/pp class="cY" subplot(2,2,1)
%2*2/pp class="cY" plot(x,sin(x))/pp class="" subplot(2,2,2)
%/pp class="cY" plot(x,cos(x))/pp class="cY" subplot(2,2,3)
%/pp class="cY" plot(x,sin(3*x))/pp class="cY" subplot(224)
%/pp plot(x,cos(3*x)) /pp class="cY"clf/pp class="cY" clf
%/pp class="cY"3. /pp class="cY"hold/pp class="cY"/pp class="cY"
hold on
%/pp class="cY"
hold off
%/pp class="cY"
hold
%/pp class="cY"hold onMATLAB/pp class="cY"4.7sinx[0 2]cosx[- ]4.7(a)/pp class="cY" x1=0:0.1:2*pi;/pp class="cY" plot(x1,sin(x1))/pp class="cY" hold on/pp class="" x2=-pi:.1:pi;/pp plot(x2,cos(x2)) /pp class="cY"02-2/pp class="cY"4. /pp class="cY"/pp class="cY"
plotyy(x1,y1,x2,y2)%/pp class="cY"(x1,y1)(x2,y2)/pp class="cY"4.7plotyy4.7(b)/pp plotyy(x1,sin(x1),x2,cos(x2)) /pp class="cY"plotyy-2/pp class="cY"4.1.4/pp class=""plot4.2 /pp class=""4.2 /pp class=""/pp class=""/pp class=""/p
p class=""/pp class=""/pp class=""/pp class=""/pp class=""/pp class=""/p
p class="cY"/pp class="cY"()/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class=""y(Yellow)/pp class=""m(Magenta)/pp class=""c(Cyan)/pp class=""r(Red)/pp class=""g(Green)/pp class=""b(Blue)/pp class=""w(White)/pp class=""k(Black)/pp class="cY"()/pp class="cY"/pp class="cY"/pp class="cY"/pp class=""-/pp class="":/pp class=""-./pp class=""--/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class="cY"/pp class=""./pp class=""o/pp class=""x/pp class=""+/pp class=""*/pp class=""s/pp class=""d/pp class=""v/pp class=""^/pp class=""
p
h
plot(x,y,s)
xyss
4.8sinxcosx4.8
x=0:0.1:2*pi;
plot(x,sin(x),'r-.')
%
hold on
plot(x,cos(x),'b:o')
%
4.1.5
1.
axis4.3
4.3
axis auto
axis equal
axis manual
axis fill
manual
axis off
axis image
axis on
axis normal
axis ij
axis square
axis xy
axis tight
axis([xmin,xmax,ymin,ymax])
xmin background > none
2
xdatax
ydatay
3
drawnow
4
(1) EraseModexorbackgroundnone
(2) xdataydata()
(3) drawnow
4.344.55
x=0:0.1:20;
y=1-1/sqrt(1-0.3^2)*exp(-0.3*x).*sin(sqrt(1-0.3^2)*x+acos(0.3));
plot(x,y)
h=line(0,0,'color','red','marker','.','markersize',40,'erasemode','xor');%
for i=1:length(x)
set(h,'xdata',x(i),'ydata',y(i)); %
pause(0.005)
%0.005
drawnow
%
end
xorEraseModebackgrounddrawnowMATLABsetpausedrawnow
5 MATLAB
5.1
MMM
5.1.1 M
MATLABMM(EditorDebugger)
MATLABFileNewM-fileMMM5.1M
5.1.2 M
Myx
)
cos
a
x
1
sin(
e
1
1
1
y
2
x
2
V
+
V
-
V
-
-
=
V
-
5.1M5.2M
5.1M
%EX0501
%0.3
x=0:0.1:20;
y1=1-1/sqrt(1-0.3^2)*exp(-0.3*x).*sin(sqrt(1-0.3^2)*x+acos(0.3))
plot(x,y1,'r')
5.2zeta
function y=Ex0502(zeta)
% EX0502 Step response of quadratic system.
%
% zeta
% y
%
% copyright 2003-08-01
x=0:0.1:20;
y=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta))
plot(x,y)
M
H1(%)
(%)
(%)
helplookfor
help Ex0502
EX0502 Step response of quadratic system.
zeta
y
lookfor ''
Ex0502.m: %
5.1.3 M
(1)
(2) MATLABMATLAB
(3) MATLAB(workspace)clear
5.1MM
(1) MATLABM
(2) MEx0501.m
%EX0501
x=0:0.1:20;
y1=1-1/sqrt(1-0.3^2)*exp(-0.3*x).*sin(sqrt(1-0.3^2)*x+acos(0.3))
plot(x,y1,'r')
%0.3
hold on
y2=1-1/sqrt(1-0.707^2)*exp(-0.707*x).*sin(sqrt(1-0.707^2)*x+acos(0.707))
plot(x,y2,'g')
%0.707
y3=1-exp(-x).*(1+x)
plot(x,y3,'b')
%1
(3) MDebugRun5.2
whos
Name Size Bytes Class
x 1x201 1608 double array
y1 1x201 1608 double array
y2 1x201 1608 double array
y3 1x201 1608 double array
Grand total is 804 elements using 6432 bytes
5.1.4 M
(1) function
function [] = ()
(2)
(3) return
(4) MMATLAB
5.2MMMATLAB
M
(1)
function y=Ex0502(zeta)
%EX0502
x=0:0.1:20;
y=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta))
plot(x,y)
(2) Ex0502.m
(3) MATLABf
f=Ex0502(0.3)
Ex0502zetay
xy
x
??? Undefined function or variable 'x'.
y
??? Undefined function or variable 'y'.
MMMATLAB
5.2
5.2.1 for ... end
for =array
end
arrayarrayarray
5.3for ... endarray 1+3+5...+100
% EX0503 for
sum=0;
for n=1:2:100
sum=sum+n;
end
sum
sum =
2500
sum =2500
nn1:2:100n
5.4for ... endarray
% EX0504 for
sum=zeros(6,1);
for n=eye(6,6)
sum=sum+n;
end
sum
sum =
1
1
1
1
1
1
neye(6,6)n[1;0;0;0;0;0]n[0;1;0;0;0;0]6
5.2.2 while ... end
while
end
nanMATLAB
5.55.31+3+5...+100
% EX0505 while
sum=0;
n=1;
while n> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
mexy
Select a compiler:
[1] Digital Visual Fortran version 6.0 in C:\Program Files\Microsoft Visual Studio
[2] Lcc C version 2.4 in D:\MATLAB6P1\sys\lcc
[3] Microsoft Visual C/C++ version 6.0 in D:\Program Files\Microsoft Visual Studio
[0] None
MEX3
Please verify your choices:
Compiler: Microsoft Visual C/C++ 6.0
Location: D:\Program Files\Microsoft Visual Studio
Are these correct?([y]/n):
y
The default options file:
"D:\Documents and Settings\ZJDCY\Application Data\MathWorks\MATLAB\R12\mexopts.bat"
is being updated from D:\MATLAB6P1\BIN\WIN32\mexopts\msvc60opts.bat...
Installing the MATLAB Visual Studio add-in ...
Updated D:\Program Files\Microsoft Visual Studio\common\msdev98\template\MATLABWizard.awx
from D:\MATLAB6P1\BIN\WIN32\MATLABWizard.awx
Updated D:\Program Files\Microsoft Visual Studio\common\msdev98\template\MATLABWizard.hlp
from D:\MATLAB6P1\BIN\WIN32\MATLABWizard.hlp
Updated D:\Program Files\Microsoft Visual Studio\common\msdev98\addins\MATLABAddin.dll
from D:\MATLAB6P1\BIN\WIN32\MATLABAddin.dll
Merged D:\MATLAB6P1\BIN\WIN32\usertype.dat
with D:\Program Files\Microsoft Visual Studio\common\msdev98\bin\usertype.dat
2.
MATLABMATLABextern\examples\mex
mex yprime.c
extern\examples\mexyprime.dllyprime.dll
>> which yprime
D:\MATLAB6p1\extern\examples\mex\yprime.dll
yprime.dll
>> yprime(1,1:2:7)
ans =
3.0000 14.9925 7.0000 -1.0377
3. CMEX
(1)
MATLABmexFunction
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] )
{
/*MATLAB*/
}
mexFunction
nrhs
prhs
nlhs
plhs
(2)
4. CMEX
(1) MATLAB API
MEXMATLAB API
mxGetM
mxGetN
mxGetPr
mexErrMsgTxtMATLAB
mxCreateString
mxCreateDoubleMatrix
mxIsDouble
(2) CMEX
MEX
8.1Microsoft Visual C++6.0MEX
Microsoft Visual C++6.0C++ Source FileEx0801.cpp
#include "mex.h"
#include "math.h"
/*Ex0801*/
void Ex0801(double y[],double x[])
{
y[0]=1/(x[0]*x[0]);
return;
}
/*mexFunction*/
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
double *x,*y;
unsigned int m,n;
/**/
if(nrhs!=1)
{
mexErrMsgTxt("Only one input argument allowed.");
}
/**/
else if(nlhs!=1){
mexErrMsgTxt("Only one output argument allowed.");
}
m = mxGetM(prhs[0]);
n = mxGetN(prhs[0]);
/**/
if (!mxIsDouble(prhs[0]) || mxIsSparse(prhs[0]) ||mxIsComplex(prhs[0])||
! (m==1&&n==1))
{
mexErrMsgTxt("Input argument must be a scalar.");
}
/**/
plhs[0]=mxCreateDoubleMatrix(m,n,mxREAL);
y = mxGetPr(plhs[0]);
x = mxGetPr(prhs[0]);
/**/
Ex0801(y,x);
}
MATLABMEX
mex Ex0801.cpp
>> y=Ex0801(2)
y =
0.2500
cppC++Ex0801.dllEx0801.dll
M
MATLABEx0801.dllEx0801.M
%function y=Ex0801(x)
%
% y=1/(x^2)
% copyright @ 2003-10-10
MATLABhelpM
>> help Ex0801
function y=Ex0801(x)
y=1/(x^2)
copyright @ 2003-10-10
8.1.2 MATLABMEXEXE
1. MEXEXE
MEXMATLABEXEMATLAB
2.
MEX8.1MATLAB CompilerEXE
3. MC MEX
MATLABMMEXmcc x
8.2MATLABM
MATLAB/Ex0802.m
function Ex0802
% Ex0802
x=0:0.1:2*pi;
y=sin(x);
plot(x,y)
MATLABMMEX
>> mcc -x Ex0802
%Ex0802.dll
>> Ex0802
%Ex0802.dll
Ex0802.dlldllEx0802.cEx0802.hEx0802_mex.c
Ex0802.mMmcc
>> mcc -x Ex0802
??? Error: Cannot create MEX File "Ex0802" from MEX File "C:\My Documents\CAOYi\BookMATLAB\20031008\exe\Ex0802.dll".
Error in ==> D:\MATLAB6p1\toolbox\compiler\mcc.dll
4. EXE
8.3mbuildCEXE
matlab\extern\examples\cmathex1.cEXE
matlab\extern\examples\cmathmbuildLCCMicrosoft Visual C/C++MATLAB
>> mbuild ex1.c
Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc C version 2.4 in D:\MATLAB6P1\sys\lcc
[2] Microsoft Visual C/C++ version 6.0 in D:\Program Files\Microsoft Visual Studio
[0] None
Compiler: 2
mbuild -setup
(1) mbuildCEXE
8.3mbuildCEXE
mbuildex1.c
>> mbuild ex1.c
ex1.exeMATLABbin
(2) mccMEXE
8.4mcc8.2MEXE
>> mcc -B sglcpp Ex0802.m
%C++
MCCmbuild-cmcc -mcmcc -pc
8.2
8.2.1
1.
fid = fopen(filename,permission)
%
[fid,message] = fopen(filename,permission) %
fid(File Identifier)-1messagefilenameMATLABpermission
'r'
'r+'
'w'
'w+'
'a'
'a+'
fopenpermissiontpermissionb'wb''rb+'
2.
status=fclose(fid)
%
status=fclose('all')
%
status0-1fid
8.5
Ex0805.txtMATLAB
type Ex0805.txt
a 1 2 3
b 4 5 6
fopenfclose
[fid,message]=fopen('Ex0805.txt','w+')
%
fid =
3
message =
''
if fid==-1
disp('')
else
disp('')
end
status=fclose(fid)
%
status =
0
8.2.2
1. fscanf
fscanf
[a,count]=fscanf(fid,format,size)
%
fidformat%%c%d%e%f%g%i%o%s%u%x(C)countasizesize
nn
inf
[m,n]mn0
8.5Ex0805.txt
fid=fopen('Ex0805.txt')
fid =
3
a1=fscanf(fid,'%s',4)
%
a1 =
a123
fclose(fid)
ans =
0
2. fprintf
fprintf
count=fprintf(fid,format,a,)
%
fidaafidformatfscanf%E%G%X-()+()0()count
8.6Ex0805.txt
a='%This is a example.';
fid=fopen('Ex0805.txt','a+')
%Ex0803.txt
fid =
3
fprintf(fid,'%s',a)
%a
ans =
19
fclose(fid)
%
ans =
0
fid=fopen('Ex0805.txt','r')
%Ex0803.txt
fid =
3
fscanf(fid,'%s')
%
ans =
a123b456%Thisisaexample.%Thisisaexample.%Thisisaexample.%Thisisaexample.
fclose(fid)
ans =
0
3. fgetlfgets
fgetlfgetsfgetlfgets
tline=fgetl(fid)
%
tline=fgets(fid)
%
tline=fgets(fid,nchar)
%
fidtline-1nchar
8.6Ex0805.txt
fid=fopen('Ex0805.txt','r') ;
%Ex0803.txt
fgetl(fid)
%
ans =
a 1 2 3
fgets(fid)
%
ans =
b 4 5 6
fgets(fid,10)
%10
ans =
%This is a
fgets(fid,10)
ans =
example.%
8.2.3
fread
[a,count]=fread(fid,size,precision,skip)
%
fidsizefscanfprecision'uchar''schar''int8''int16''int32''int64''unit8''unit16''unit32''unit64''single''float32''double''float64'acountskip
2.
fwrite
count=fwrite(fid,a,precision,skip)
%
fidaprecisionskipfreadcount
8.7MAT
x1=1:10;
[fid,message]=fopen('Ex0805.mat','a')
%
fid =
4
message =
''
count1=fwrite(fid,x1)
%
count1 =
10
x2=11:15;
count2=fwrite(fid,x2)
%
count2 =
5
status=fclose(fid);
fid=fopen('Ex0805.mat','r');
%
a1=fread(fid,[2,5])
%
a1 =
1 3 5 7 9
2 4 6 8 10
a2=fread(fid,[1,5])
a2 =
1 2 3 4 5
fclose(fid);
8.2.4
1. fseek
fseek
status=fseek(fid,offset,origin)
%
fidoffsetoffset >00status0-1origin
'bof' -1
'cof' 0
'eof' 1
2. ftell
ftell
pos=ftell(fid)
%
pos
3. frewind
frewind
frewind(fid)
4. feof
feof10
feof(fid)
8.8matEx0808_1.mat110Ex0808_2.mat123
Ex0808.m
% Ex0808
x=1:10;
s=0;
fid1=fopen('Ex0808_1.mat','w+')
%
fwrite(fid1,x);
%
frewind(fid1);
%
while feof(fid1)==0
%
a1=fread(fid1,1)
%
if isempty(a1)==0
%
s=a1+s
%
end
end
fclose(fid1);
y=[1 2 3];
fid2=fopen('Ex0808_2.mat','w+')
%
fwrite(fid2,y)
%
fseek(fid2,-2,'eof')
%
a2=fread(fid2,1)
%
s=s*a2
fclose(fid2);
s =
110
while
feof0isemptyfeof1
fseek(fid2,-2,'eof')2
8.3
MATLAB.figtifbmpjpgFile(ExportExport8.2
8.4 Notebook
8.4.1 Notebook
MATLAB 6.5Notebook
(1) MATLABMATLAB
(2) notebook -setup
>> notebook -setup
Welcome to the utility for setting up the MATLAB Notebook
for interfacing MATLAB to Microsoft Word
Choose your version of Microsoft Word:
[1] Microsoft Word 97
[2] Microsoft Word 2000
[3] Microsoft Word 2002 (XP)
[4] Exit, making no changes
Microsoft Word Version:
(3) Word2
Notebook
Notebook setup is complete.
winword.exenormal.exe
8.4.2 Notebook
1. M-book
(1) WordNotebook
M-book
Word(m-book.dot8.3Word2000The MATLAB Notebook v1.doc
(2) MATLABNotebook
MATLABnotebookNotebook
notebook
%M-book
notebook FileName
%M-book
FileName
M-book
>> notebook 'C:\My Documents\MyMbook0801.doc'
2. M-book
M-bookWordNotebookNotebook8.4
8.1
8.1 Notebook
Define Input Cell
Alt+I
Define AutoInit Cell
Alt+A
Define Calc Zone
Alt+Z
Undefine Cells
Alt+U
Purge Output Cells
Alt+P
Group Cells
Alt+G
Ungroup Cells
Alt+p
Hide/Show Cell Markers
Alt+C
/
Toggle Graph Output for cell
Evaluate Cell
Ctrl+Enter
Evaluate Calc Zone
Alt+Enter
Evaluate M-book
Alt+M
M-book
Evaluate Loop
Alt+L
Bring MATLAB to front
MATLAB
Notebook Options
Alt+O
8.4.3 Notebook
NotebookMATLABAutoInitCalcErrorInputNographOutputWordNotebook8.2
8.2 M-book
Input
10 (points)Courier New
Output
()
10(points)Courier New
AutoInit
10(points)Courier New
Error
10(points)Courier New
1.
(1)
MATLABAlt-DNotebookDefine Input Cell
8.9M-book(M-book)
x=1:0.1:3;
x=1:0.1:3;Alt-D
x=1:0.1:3;
(2)
MATLABCtrl-EnterNotebookEvaluate Cell
8.9
MATLAB
y=sin(x)
y=sin(x)Ctrl-Enter
xMATLABM-bookMATLABy=sin(x)
2.
MATLABNotebookDefine AutoInit CellMATLABAutoInit
3.
(1) MATLABNotebookDefine Input CellNotebookDefine AutoInit Cell
(2) NotebookGroup Cells
8.9
M-book
NotebookGroup Cells
4.
MATLAB
8.9
Ctrl-Enter
y[]
5.
8.10
WordNotebook(Define Calc ZoneNotebook(Define Input CellNotebook(Evaluate Calc Zone
[]
6.
NotebookUndefine CellsAlt-UNormal
8.4.4 NotebookMATLAB
1.
clear
2. M-book
NotebookEvaluate M-bookM-bookMATLAB
3.
NotebookNotebook Options8.5
(1)
8.5Numeric Format8ShortLongHexBankPlusShorteRational
(2)
8.5LooseCompact
(3)
Embed Figures in M-bookM-book
(4)
8.5Figure OptionsUnitsWidthHeightUnitsInchesCentimetersPoints
(5)
(6)
Word/
/
Notebook OptionsEmbed Figures in M-bookOK
MATLAB
8.11peaks
NotebookNotebook OptionsWidthHeight2Evaluate M-bookM-book
4.
NotebookNotebookEvaluate Loop8.6
5. M-book
NotebookPurge Selected output Cells
1.1 MATLAB 6.5
//
1.2 File
1.3 Edit
1.4 View
1.5 Web
1.6 Help
New M-File
Copy
Cut
Paste
Open File
Undo
Redo
Help
Simulink
1.8
1.9
1.10
1.11
1.13
MMAT
1.14
1.15 Array Editor
1.16
1.17 M
1.18
1.19
1.21
1.22
1.23
1.24
1.25 M
1.26
1.27
2.4
2.5
2.6
2.7
2.8
2.9
2.10
3.1
3.2 (a) y(x)[-22] (b) y(x)[0100]
3.3
3.4 (a) Figure No. 1 (b) Figure No. 2
3.4 (c) Figure No. 3
4.1 (a) x1 (b) x2
4.2 (a) (b)
4.3 (a) x1 (b) x2
4.4 (a) (x1,y1) (b) (x2,y1)
4.4 ( c) (y1,x1) (d) (y2,x1)
4.4 (e) (x2,y1)
4.5
4.6
4.7 (a) hold on (b) plotyy
4.8
4.9
4.10
4.11
EMBED PBrush
4.12
4.13 (a) xx (b) yy
4.14 peaks
4.15 peaks
4.16 peaks
4.17 (a) peaks (b) peaks
4.18 peaks
4.19 (a) (0,0)peaks (b) (0,90)peaks
4.20 peaks
4.21rgbplotcolorbar
4.22interpfaceted
4.23 (a) (b)
4.24 (a) (b)
4.25
4.26
4.27
4.28
4.29
4.30 (a) (b)
4.31 (a) (b)
EMBED PBrush
4.32
4.33 (a) Edit (b) Insert
4.34
4.35
4.36
4.39
4.38
4.40
Root()
Figure()
Uicontrol()
Axes()
Uimenu()
Line
()
Surface
()
Rectangle
()
Patch
()
Image
()
Text
()
Light
()
4.41
4.43
4.44 Guide
4.45
4.47 (a) (b)
4.50
4.52
4.53
4.54
4.55
5.1 M/
5.2
function Ex0513()
% EX0513
z1=0.3;
[x1,y1]=Ex0502(z1);
plot(x1,y1)
hold on
z1=0.5;
[x2,y2]=Ex0502(z1);
plot(x2,y2)
z1=0.707;
[x3,y3]=Ex0502(z1);
plot(x3,y3);
function [x,y]=Ex0502(zeta)
%
x=0:0.1:20;
y=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
function [x,y]=Ex0502(zeta)
%
x=0:0.1:20;
y=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin...
(sqrt(1-zeta^2)*x+acos(zeta));
5.3
5.4
5.5
5.6
EMBED PBrush
5.7 humps
5.8 humps
EMBED PBrush
(t,y(2))
(t,y(1))
5.9
5.10
u(t)
G1(s)
G2(s)
y(t)
6.1
y(t)
u(t)
G1(s)
G2(s)
6.2
y(t)
u(t)
G1(s)
G2(s)
6.3
6.4
-
G1(s)
G2 (s)
G3 (s)
-
G4 (s)
y(t)
u(t)
6.5
-
-
1/s
1/(s2+s)
1/(s2+s)
-2
1/s
1/s+1
7
6
5
4
3
2
1
6.6
-1
1/s
1/(s2+s)
1/(s2+s)
-2
1/s
-1/s+1
6.7
6.8
6.9
6.10
6.11 (a) (b)
6.12
6.13
6.14 (a) Bode (b) semilogx
6.15 nyquist
6.16 nichols
6.17 bode
6.18
6.19
6.20 (a) n (b)
6.21
7.1 Simulink
7.2 Simulink
7.3 Simulink
7.4
7.5
EMBED PBrush
7.6
exe
7.7
7.8
7.9
7.10
7.11
7.13
7.14
7.15 (a) (b)
7.16 From File
7.18
7.17
X-Y
X
7.19
Y
7.22
7.23
7.24 Solver
7.25 Workspace I/O
7.26 Sum
7.27
7.28
7.29
7.30 plot
7.31
7.32 T=Tk=0.1 (a) d(k) (b) y(t)
7.33 T=0.6 Tk=0.1 (a) d(k) (b) y(t)
7.34 T=0.6 Tk=0.1 (a) d(k) (b) y(t)
7.35
7.36
7.38
7.37
7.39
7.41 (a) Enable (b) Out1
7.42 (a) (b)
7.43 (a) (b)
7.44 Icon
7.45 Parameters
7.46
7.47
7.48 (a) Parameters (b) Initialization
7.48(c) Documentation
7.49 (a) (b)
7.50
7.51
7.50
8.1 MATLAB
8.2 Export
8.3 word
8.4 Notebook
y=sin(x)
y =
Columns 1 through 7
0.8415 0.8912 0.9320 0.9636 0.9854 0.9975 0.9996
Columns 8 through 14
0.9917 0.9738 0.9463 0.9093 0.8632 0.8085 0.7457
Columns 15 through 21
0.6755 0.5985 0.5155 0.4274 0.3350 0.2392 0.1411
x=1:0.1:3;
y=sin(x)
plot(x,y)
x=1:0.1:3;
y=sin(x)
plot(x,y)
x=1:0.1:3;
y=sin(x)
plot(x,y)
y =
Columns 1 through 7
0.8415 0.8912 0.9320 0.9636 0.9854 0.9975 0.9996
Columns 8 through 14
0.9917 0.9738 0.9463 0.9093 0.8632 0.8085 0.7457
Columns 15 through 21
0.6755 0.5985 0.5155 0.4274 0.3350 0.2392 0.1411
1. Ifelseend
Ifelseend
x=100*rand(1);
if x>=90
score=''
elseif x>=80
score=''
elseif x>=70
score=''
elseif x>=60
score=''
else
score=''
end
score =
8.5 Notebook Options
peaks[x,y,z]=peaks;
mesh(x,y,z)
8.6
_1133077219.unknown
_1133246738.unknown
_1133246838.unknown
_1133247002.unknown
_1133247446.unknown
_1133423477.unknown
_1141028691.unknown
_1133297809.unknown
_1133362082.unknown
_1133297244.unknown
_1133247050.unknown
_1133247307.unknown
_1133247434.unknown
_1133247435.unknown
_1133247432.unknown
_1133247433.unknown
_1133247426.unknown
_1133247267.unknown
_1133247304.unknown
_1133247026.unknown
_1133247036.unknown
_1133247011.unknown
_1133246944.unknown
_1133246951.unknown
_1133246992.unknown
_1133246947.unknown
_1133246928.unknown
_1133246936.unknown
_1133246897.unknown
_1133246782.unknown
_1133246787.unknown
_1133246835.unknown
_1133246784.unknown
_1133246769.unknown
_1133246779.unknown
_1133246766.unknown
_1133245941.unknown
_1133246487.unknown
_1133246550.unknown
_1133246579.unknown
_1133246493.unknown
_1133246243.unknown
_1133246480.unknown
_1133246242.unknown
_1133161897.unknown
_1133245936.unknown
_1133245938.unknown
_1133245940.unknown
_1133245937.unknown
_1133245835.unknown
_1133245935.unknown
_1133245934.unknown
_1133209515.unknown
_1133077245.unknown
_1133124560.unknown
_1133077227.unknown
_1132993030.unknown
_1132993091.unknown
_1132993238.unknown
_1133074911.unknown
_1133077192.unknown
_1132993239.unknown
_1132993102.unknown
_1132993232.unknown
_1132993235.unknown
_1132993111.unknown
_1132993231.unknown
_1132993094.unknown
_1132993049.unknown
_1132993072.unknown
_1132993082.unknown
_1132993053.unknown
_1132993042.unknown
_1132993045.unknown
_1132993034.unknown
_1132945086.unknown
_1132992617.unknown
_1132992979.unknown
_1132993007.unknown
_1132992772.unknown
_1132992608.unknown
_1132992613.unknown
_1132948173.unknown
_1132948182.unknown
_1132936321.unknown
_1132936421.unknown
_1132936596.unknown
_1132936329.unknown
_1130047378.unknown
_1132935869.unknown
_1132936258.unknown
_1132686275.unknown
_1130661583.unknown
_1130046938.unknown