- 0
- 0
- 约8.51千字
- 约 38页
- 2019-12-02 发布于江苏
- 举报
上节课作业 题目1:上网查询矩阵行列式的定义,随机生成一个3阶方阵,用定义及matlab自带函数分别计算其行列式的值。 A=rand(3) A = 0.9501 0.4860 0.4565 0.2311 0.8913 0.0185 0.6068 0.7621 0.8214 a=(A(1,1)*A(2,2)*A(3,3)+A(1,2)*A(2,3)*A(3,1)+ A(1,3)*A(2,1)*A(3,2))- (A(1,3)*A(2,2)*A(3,1)+A(1,1)*A(2,3)*A(3,2)+ A(1,2)*A(2,1)*A(3,3)) a = 0.4289 b=det(A) b = 0.4289 题目2:用matlab求解下列方程组 A=[-1 2 0;2 1 1;4 5 7;1 1 5]; b=[2;3;0;-5]; x=A\b x = 1.1818 1.3766 -1.5974 A*x-b ans = -0.4286 -0.8571 0.4286 -0.4286 题目3:已知f(x)=4x3+7x2-5x+3,g(x)=7x2-2x+1,用roots(上网查询或使用matlab帮助)命令及图像法求出f(x)*g(x)=0的解。 f=[4 7 -5 3] f = 4 7 -5 3 g=[7 -2 1] g = 7 -2 1 p=conv(f,g) p = 28 41 -45 38 -11 3 help roots ROOTS Find polynomial roots. ROOTS(C) computes the roots of the polynomial whose coefficients are the elements of the vector C. If C has N+1 components, the polynomial is C(1)*X^N + ... + C(N)*X + C(N+1). See also POLY, RESIDUE, FZERO. Overloaded methods help gf/roots.m help localpoly/roots.m roots(p) ans = -2.4008 0.3254 + 0.4544i 0.3254 - 0.4544i 0.1429 + 0.3499i 0.1429 - 0.3499i polyval(p,ans(1,1)) ans = 7.2742e-013 polyval(p,-2.4008) ans = -0.0198 y_c=inline((4*x.^3+7*x.^2-5*x+3).*(7*x.^2-2*x+1)) y_c = Inline function: y_c(x) = (4*x.^3+7*x.^2-5*x+3).*(7*x.^2-2*x+1) x=-10:0.01:10; y=y_c(x); plot(x,y,r) hold on plot(x,zeros(size(x))) hold off zoom on %获局部放大图 [tt,yy]=ginput(5);zoom off tt tt = -0.9908 -0.4378 0.5300 1.9124 -2.7880 yy yy = 1.0e+004 * 5.9942 -4.2398 -4.2398 -4.2398 5.9942 for n=1:4 [xx(n),yyv(n)]=fzero(y_c,tt(n)); end xx xx = -2.4008 -2.4008 -2.4008 -2.4008 题目4:已知数据如下,请用2阶及4阶多项式对数据进行拟合,并比较拟合效果。 x=[0.0129 0.0247 0.0530 0.1550 0.3010 0.4710 0.8020 1.2700 1.4300 2.4600]; y=[9.5600 8.1845 5.2616 2.7917 2.2611 1.7340 1.2370 1.0674 1.1171 0.7620]; q=polyfit(x,y,2);w=polyfit(x,y,4); e=0:0.0001:3; r=poly
原创力文档

文档评论(0)