语法知识
8.1 差分与近似微分
8.2 微分运算
8.3 不定积分与定积分计算
8.4 数值积分
实例演练
8.1
♥dim取1和2的区别:
>> X=magic(4)
X =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
>> Y1=diff(X)
Y1 =
-11 9 7 -5
4 -4 -4 4
-5 7 9 -11
>> Y2=diff(X,1,2)
Y2 =
-14 1 10
6 -1 -2
-2 -1 6
10 1 -14
♥
>> t=1:10;
>> s=[2 6 12 20 30 42 56 72 90 110];
>> v=diff(s)./diff(t)
v =
4 6 8 10 12 14 16 18 20
>> a=diff(v)./diff(t(1:9))
a =
2 2 2 2 2 2 2 2
8.2
♥微分:
>> syms x
>> y=x*sin(x)+15;
>> diff(y)
ans =
sin(x) + x*cos(x)
>> x=pi/4;
>> eval(ans)
ans =
1.2625
♥六阶微分:
>> syms x
>> y=x^6;
>> diff(y,6)
ans =
720
♥偏微分:
>> syms x t
>> y=exp(-t)*sin(x*t);
>> yt=diff(y,'t')
yt =
x*exp(-t)*cos(t*x) - exp(-t)*sin(t*x)
♥:
>> syms x t
>> y=exp(t)*(sin(t)+cos(t));
>> t=log(x);
>> yx=diff(y)*diff(t)
yx =
(exp(t)*(cos(t) + sin(t)) + exp(t)*(cos(t) - sin(t)))/x
>> simple(yx)
未定义函数或变量 'simple'。
>> simplify(yx)
ans =
(2*exp(t)*cos(t))/x
注:化简用simplify
8.3
♥求简单不定积分:
>> syms x
>> y=1/(1+x^2);
>> R=int(y)
R =
atan(x)
♥代参变量积分:
>> syms a b x
>> y=exp(a*x)*sin(b*x);
>> R=int(y)
R =
-(exp(a*x)*(b*cos(b*x) - a*sin(b*x)))/(a^2 + b^2)
>> R=int(y,a)
R =
(exp(a*x)*sin(b*x))/x
♥ 求椭圆面积:
>> syms a b t
>> x=a*cos(t);
>> y=b*sin(t);
>> S=y*diff(x)
S =
-a*b*sin(t)^2
>> A=int(S,2*pi,0)
A =
pi*a*b
♥抛物线椭圆函数与xy面围成的体积:
>> syms x y
>> z=10-x^2/4-y^2/9;
>> V=int(int(z,x,-4,4),y,-4,4)
V =
13952/27
>> eval(V)
ans =
516.7407
8.4
♥求y=sinx的均方根值(其中修改步长为π/1000):
>> x=0:pi/1000:pi;
>> y=sin(x).^2;
>> delta=pi/1000;
>> z=(1/pi*delta*trapz(y))^(1/2)
z =
0.7071
♥:
>> syms x y
>> V=int(int(6-x.^2/4-y.^2/9,y,-4,4),x,-4,4)
V =
7040/27
>> eval(V)
ans =
260.7407
>> [X,Y]=meshgrid(-4:0.2:4);
>> Z=6-X.^2/4-Y.^2/9;
>> surfc(X,Y,Z)
>> colormap(jet)
总结思考
emmmm发现很多基本数学知识自己还没有掌握很好,所以在练习的过程中,函数会使用,但是有些不理解计算方法,能解决的自己也尽量已通过各种渠道解决了,其余的还是应该加强自己的数学功底才行~~~T^T