?? program_0.1.m
字號:
% Chapter 0 - A Tutorial Introduction to MATLAB and the Symbolic Math Package.
% Tutorial One - The Basics.
% Copyright Birkhaser 2002. Stephen Lynch.
% These commands should be run in the Command Window.
clear
3^2*4-3*2^5*(4-2) % Simple arithmetic.
sqrt(16) % Square root.
u=1:2:9 % A vector.
v=u.^2 % Square the elements.
A=[1,2;3,4] % A 2x2 matrix.
A' % The transpose.
det(A) % The determinant.
B=[0,3,1;.3,0,0;0,.5,0] % A 3x3 matrix.
eig(B) % The eigenvalues of B.
[Vects,Vals]=eig(B) % Eigenvectors and eigenvalues.
C=[100;200;300] % A 3x1 matrix.
D=B*C % Matrix multiplication.
E=B^4 % Powers of matrices.
z1=1+i % Complex numbers.
z2=1-i
z3=2+i
z4=2*z1-z2*z3 % Complex arithmetic.
abs(z1) % Modulus.
real(z1) % Real part.
imag(z1) % Imaginary part.
exp(i*z1) % Exponential.
sym(1/2)+sym(3/4) % Symbolic arithmetic.
1/2+3/4 % Double precision.
vpa(pi,50) % Variable precision.
syms x y z % Symbolic objects
z=x^3-y^3
factor(z) % Factorization.
expand(ans) % Expansion.
simplify(z/(x-y)) % Simplification.
syms a b
[a,b]=solve('tau*x*y','tau*x*y-y') % Solving simultaneous equations.
f='mu*x*(1-x)' % Define a function.
subs(f,x,1/2) % Evaluate f(1/2).
fof=subs(f,x,f) % Composite function.
limit(x/sin(x),x,0) % Limits.
diff(f,x) % Differentiation.
diff('x^2+3*x*y-2*y^2','y',2) % Partial differentiation.
int('sin(x)*cos(x)',x,0,pi/2) % Integration.
int('1/x',x,0,inf) % Improper integration.
syms n s w
s1=symsum(1/n^2,1,inf) % Symbolic summation.
g=exp(x)
taylor(g,10) % Taylor series.
laplace(x^3) % Laplace transform.
ilaplace(1/(s-a)) % Inverse transform.
fourier(exp(-x^2)) % Fourier transform.
ifourier(pi/(1+w^2)) % Inverse transform.
% End of Tutorial One.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -