⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program_01.m

📁 《Dynamical Systems with Applications using MATLAB》源代码
💻 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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -