用MATLAB求解计算方法的习题1.docx

上传人:b****5 文档编号:3293740 上传时间:2022-11-21 格式:DOCX 页数:11 大小:73.56KB
下载 相关 举报
用MATLAB求解计算方法的习题1.docx_第1页
第1页 / 共11页
用MATLAB求解计算方法的习题1.docx_第2页
第2页 / 共11页
用MATLAB求解计算方法的习题1.docx_第3页
第3页 / 共11页
用MATLAB求解计算方法的习题1.docx_第4页
第4页 / 共11页
用MATLAB求解计算方法的习题1.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

用MATLAB求解计算方法的习题1.docx

《用MATLAB求解计算方法的习题1.docx》由会员分享,可在线阅读,更多相关《用MATLAB求解计算方法的习题1.docx(11页珍藏版)》请在冰豆网上搜索。

用MATLAB求解计算方法的习题1.docx

用MATLAB求解计算方法的习题1

作业

1.矩阵运算

例9.4.6

>>Matrix_B=[123;234;345]

Matrix_B=

123

234

345

例9.7

>>formatrat

>>H=hilb(3)

H=

11/21/3

1/21/31/4

1/31/41/5

例9.8

>>M=magic(3)

M=

816

357

492

>>M=magic(4)

M=

162313

511108

97612

414151

例9.9矩阵加减

>>A=[111;123;136];B=[816;357;492];

>>A+B

ans=

927

4710

5128

>>A-B

ans=

-70-5

-2-3-4

-3-64

例9.10矩阵相乘和数乘矩阵

>>X=[2345;1221];

>>Y=[011;

110;

001;

100];

>>Z=X*Y

Z=

856

333

>>a=2*X

a=

46810

2442

例9.11矩阵的除法

>>a=[123;426;749];

>>b=[4;1;2];

>>x=a\b

x=

-3/2

2

1/2

例9.12求A的逆矩阵

>>A=[123;221;343];

>>Y=inv(A)

Y=

13-2

-3/2-35/2

11-1

例9.13求A的行列式

>>a=[123;456;789];

>>D=det(a)

D=

1/150********90165

2符号表达式运算

例9.1提取表达式中的分母和分子

执行的结果出错。

例9.2标准代数计算

>>f='2*x^2+3*x-5';

>>g='x^2-x+7';

>>sym(f)+sym(g)

ans=

3*x^2+2*x+2

>>sym(f)-sym(g)

ans=

x^2+4*x-12

>>sym(f)*sym(g)

ans=

(x^2-x+7)*(2*x^2+3*x-5)

>>sym(f)/sym(g)

ans=

(2*x^2+3*x-5)/(x^2-x+7)

例9.3求复合函数

执行结果出错。

例9.5符号表达式画图

>>y='-16*x^2+64*x+96';

>>ezplot(y)

例9.6符号表达式简化和格式化

>>f=sym('(x^2-1)*(x-2)*(x-3)');

>>collect(f)

ans=

x^4-5*x^3+5*x^2+5*x–6

>>factor(f)

ans=

(x-1)*(x+1)*(x-2)*(x-3)

>>expand(f)

ans=

x^4-5*x^3+5*x^2+5*x-6

>>simplify('log(2*x/y)')

ans=

log(2*x/y)

例9.7符号矩阵的生成

执行结果错误。

例9.9求极限

>>symsxathn;

>>L1=limit((cos(x)-1)/x)

L1=

0

>>L2=limit(1/x^2,x,0,'right')

L2=

Inf

>>L3=limit(1/x,x,0,'left')

L3=

-Inf

>>L4=limit((log(x+h)-log(x))/h,h,0)

L4=

1/x

>>v=[(1+a/x)^x,exp(-x)];

>>L5=limit(v,x,inf,'left')

L5=

[exp(a),0]

>>L6=limit((1+2/n)^(3*n),n,inf)

L6=

exp(6)

例9.10求符号函数的微分

>>f='a*x^3+x^2-b*x-c';

>>diff(f)

ans=

3*a*x^2+2*x-b

>>diff(f,2)

ans=

6*a*x+2

>>diff(f,'a')

ans=

x^3

>>diff(f,'a',2)

ans=

0

例9.11求符号函数的积分

>>f='a*x^3+x^2-b*x-c';

>>diff(f)

ans=

3*a*x^2+2*x-b

>>diff(f,2)

ans=

6*a*x+2

>>diff(f,'a')

ans=

x^3

>>diff(f,'a',2)

ans=

0

>>f='sin(s+2*x)';

>>int(f)

ans=

-cos(s+2*x)/2

>>int(f,pi/2,pi)

ans=

-cos(s)

>>int(f,'m','n')

ans=

sin(n+s/2)^2-sin(m+1/2*s)^2

>>int(f,'s')

ans=

-cos(s+2*x)

>>int(f,'s',pi/2,pi)

ans=

cos(2*x)-sin(2*x)

例9.12单个代数方程的求解

>>solve('a*x^2+b*x+c')

ans=

-(b+(b^2-4*a*c)^(1/2))/(2*a)

-(b-(b^2-4*a*c)^(1/2))/(2*a)

例9.13单个微分方程的求解

>>dsolve('Dy=1+y^2')

ans=

i

-i

tan(C3+t)

3图形可视化

1二维图形的绘制

例9.1

>>t=0:

pi/20:

2*pi;

>>plot(t,t.*cos(t),'-.r*')

>>holdon

>>plot(sin(t-pi),':

bs')

>>plot(exp(t/100).*sin(t-pi/2),'--mo')

>>plot(t,'-gx')

>>plot(sin(t),'--b<')

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 职业教育 > 中职中专

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1