数学实验期末复习
目录
一、矩阵计算
第3章
行列式 det(A)
秩 rank(A)
迹 trace(A)
特征值 eig(A)
特征向量
>> A=magic(3)
A =
8 1 6
3 5 7
4 9 2
>> det(A)
ans =
-360
>> rank(A)
ans =
3
>> trace(A)
ans =
15
>> [V,v]=eig(A)
V =
-0.5774 -0.8131 -0.3416
-0.5774 0.4714 -0.4714
-0.5774 0.3416 0.8131
v =
15.0000 0 0
0 4.8990 0
0 0 -4.8990
>> eig(A)
ans =
15.0000
4.8990
-4.8990
二、符号计算
第9章
分解 factor
合并 collect
展开 expand
极限 limit(f,x,a)
积分 int(f,x,[ , ])
级数 symsum( ,n , ,inf)
>> syms x y;
f=x^3-y^3;
>> factor(f)
ans =
[ x - y, x^2 + x*y + y^2]
>> f=x^3+x*y+y*x+y^2;
>> collect(f)
ans =
x^3 + 2*x*y + y^2
>> f=(x+y)*(x-y);
>> expand(f)
ans =
x^2 - y^2
>> f=x/sin(x)
f =
x/sin(x)
>> limit(f,x,0)
ans =
1
>> limit(f,0)
ans =
1
>> limit(f,inf)
ans =
NaN
>> int(sin(x),[0,1])
ans =
1 - cos(1)
>> int(sin)
错误使用 sin
输入参数的数目不足。
>> int(sin(x))
ans =
-cos(x)
>> syms n;
>> symsum(1/n^2,1,inf)
ans =
pi^2/6
>> symsum(1/n^4,1,inf)
ans =
pi^4/90
>> symsum(1/n^3,1,inf)
ans =
zeta(3)
>> symsum(1/n^5,1,inf)
ans =
zeta(5)
三、程序控制
第4章
条件语句
if
else
end
分段
if
elseif
else
end
选择语句
switch
case1
end
for循环
级数 向量计算
for i=1:n
end
while循环
s=1
n=1
while n<50
s=s+通项
function [y]=wisef(x)
if x>=1
y=sqrt(x);
elseif x<1 && x>0
y=1/x;
else x<=0
y=log(abs(x)+1);
end
>> wisef(3)
ans =
1.7321
>> wisef(0.5)
ans =
2
>> wisef(-1)
ans =
1
ans =
0.6931
>> wisef(0)
ans =
1
ans =
0
function [y]=price(x)
switch fix(x/100)
case {0,1}
sall=0.9;
case {2,3,4}
sall=0.8;
otherwise
sall=0.6;
end
y=x*sall
>> price(150)
y =
135
>> price(250)
y =
200
>> price(700)
y =
420
function [y]=summ(n)
y=0;
for i=1:n
y=y+1/(2*i-1);
end
>> summ(10)
ans =
2.1333
>> summ(100)
ans =
3.2843
>> summ(10000)
ans =
5.5869
function [y]=summm(n)
y=0;
i=1;
while i<=n
y=y+1/(2*i-1);
i=i+1;
end
>> summm(10)
ans =
2.1333
>> summm(100)
ans =
3.2843
>> summm(10000)
ans =
5.5869
四、作图
第5章
二维、三维作图
plot、plot3、meshgrid—>mesh\surf
ezplot、ezplot3
>> x=-1:0.1:5;
>> plot(x,sin(x))
>> x=-1:0.1:5;
>> y=-1:0.1:5;
>> [X,Y]=meshgrid(x,y)
>> mesh(X,Y,X.^2+Y.^2)
>> x=-1:0.1:5;
>> y=-1:0.1:5;
>> plot3(x,y,x.^2+y.^2)
>> x=-1:0.1:5;
>> y=-1:0.1:5;
>> [X,Y]=meshgrid(x,y)
>> plot3(X,Y,X.^2+Y.^2)
>> ezplot('x^2+y^2=9')
>> ezplot(@(x,y) x^2+y^2-9)
>> x=-1:0.1:4;
>> subplot(2,2,1)
>> y=2.*x;
>> plot(x,y)
>> subplot(2,2,2)
>> y=sin(x);
>> plot(x,y)
>> subplot(2,2,3)
>> y=abs(x);
>> plot(x,y)
>> subplot(2,2,4)
>> y=2.^x;
>> plot(x,y)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律