语言篇作业.docx

上传人:b****5 文档编号:8236473 上传时间:2023-01-30 格式:DOCX 页数:12 大小:22.04KB
下载 相关 举报
语言篇作业.docx_第1页
第1页 / 共12页
语言篇作业.docx_第2页
第2页 / 共12页
语言篇作业.docx_第3页
第3页 / 共12页
语言篇作业.docx_第4页
第4页 / 共12页
语言篇作业.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

语言篇作业.docx

《语言篇作业.docx》由会员分享,可在线阅读,更多相关《语言篇作业.docx(12页珍藏版)》请在冰豆网上搜索。

语言篇作业.docx

语言篇作业

1.

A=[34-7-12;5-742;108-5;-65-210];

B=[4-39-8]';

X=A\B或者X=inv(A)*B

X=

-1.4841

-0.6816

0.5337

-1.2429

2.

>>A=[14813;-36-5-9;2-7-12-8];

>>B=[543-2;6-23-8;-13-97];

>>C1=A*B'

C1=

19-8230

12273

-385429

>>pinv(C1)

ans=

0.00620.0400-0.0106

-0.00460.01690.0030

0.01680.02090.0150

>>C2=A'*B

C2=

-1516-2436

63-1793-105

226117-60

194684-10

>>pinv(C2)

ans=

0.00450.0165-0.02310.0136

0.00650.0059-0.01470.0174

-0.0015-0.00700.0140-0.0011

0.0024-0.00620.00140.0038

>>C3=A.*B

C3=

51624-26

-18-12-1572

-2-21108-56

>>pinv(C3)

ans=

-0.0007-0.0049-0.0017

0.05710.0125-0.0109

0.01790.01120.0067

0.01310.0171-0.0008

3.

(a)

>>I=eye(4)

I=

1000

0100

0010

0001

>>M=magic(4)

M=

162313

511108

97612

414151

>>A=ones(2,4)

A=

1111

1111

>>B=zeros(2,4)

B=

0000

0000

(b)

C=[I,[A',B'];[A;B],M]

C=

10001100

01001100

00101100

00011100

1111162313

1111511108

000097612

0000414151

C1=C([2,4,6,8],:

C1=

01001100

00011100

1111511108

0000414151

>>C2=C1(:

[2468])

C2=

1010

0110

11118

00141

>>D=C1*C2

?

?

?

Errorusing==>mtimes

Innermatrixdimensionsmustagree.

>>D=C2*C1

D=

1211612108

1112612108

111211128923523096

1414141474168155113

4%解法1

f=@(x)cos(x).*(0.5+3.*sin(x)./(1+x.^2));

>>x=linspace(0,2*pi,101)

>>y=f(x);

>>plot(x,y)

ezplot(f,[02*pi])

%解法2

clear,clc;

x=[0:

pi/50:

2*pi];

forn=1:

101,

y(n)=cos(x(n)).*(0.5+3.*sin(x(n))./(1+x(n).^2));

end

plot(x,y,'k-','linewidth',2)

5

p=[3472912];

>>x=roots(p)

x=

-0.861220337805768+1.437733895488571i

-0.861220337805768-1.437733895488571i

0.673714912889011+1.015947309410124i

0.673714912889011-1.015947309410124i

-0.958322483499818

6

>>p=[100001];

>>roots(p)

ans=

-1.000000000000002

-0.309016994374948+0.951056516295154i

-0.309016994374948-0.951056516295154i

0.809016994374947+0.587785252292473i

0.809016994374947-0.587785252292473i

7

x=[-3-5-8-9];

>>poly(x)

ans=

1252238311080

F(x)=x4+25x3+223x2+831x+1080

8

>>b=1;

>>a=[12543];

>>[r,p,k]=residue(b,a)

r=

-0.0000+0.1508i

-0.0000-0.1508i

0.0000-0.2887i

0.0000+0.2887i

p=

-0.5000+1.6583i

-0.5000-1.6583i

-0.5000+0.8660i

-0.5000-0.8660i

k=

[]

9

>>A=randn(4,6)

A=

-0.4326-1.14650.3273-0.58831.06680.2944

-1.66561.19090.17462.18320.0593-1.3362

0.12531.1892-0.1867-0.1364-0.09560.7143

0.2877-0.03760.72580.1139-0.83231.6236

>>std(A)

ans=

0.88501.12410.37791.22830.78181.2380

>>mean(A)

ans=

-0.42130.29900.26030.39310.04950.3240

>>std(A(:

))%或者std(std(A))

ans=

0.9176

>>mean(A(:

))%或者mean(mean(A))

ans=

0.1508

10.

>>B=round(rand(4,6)*32-16)

B=

1041515-35

13-1315013-15

-12-7-1110911

13215-111514

>>C=inv(B(:

1:

4))

C=

-0.02870.1329-0.3705-0.3759

0.0244-0.0525-0.02970.0063

0.0460-0.09400.29540.3313

0.03330.0194-0.0405-0.0823

11

clearclc

t=linspace(0,10,51);

forr=2:

4,

subplot(2,2,r-1);

x=r*cos(t)+3*t;

y=r*sin(t)+3;

plot(x,y)

end

12

(a)

clear,clc

a=pi/4;t=[0:

0.1:

10];

forn=1:

4

subplot(2,2,n)

plot(sin(t),sin(n*t+a))

title(['a=pi/4,N='num2str(n)],'fontsize',20)

end

(b)

clear,clc

t=[0:

0.1:

10];

m=1;

fora=[0pi/3pi/2pi]

subplot(2,2,m)

plot(sin(t),sin(2*t+a))

title(['N=2,a='num2str(a)],'fontsize',20)

m=m+1;

end

13

p=[1-403-26];

x=[-2:

0.1:

8];

y=polyval(p,x);

plot(x,y)%可以看出有三个过零点,求根发现有三个实根两个虚根

roots(p)

ans=

3.799906794547345

-1.260715576260111

1.347925320266517

0.056441730723125+0.962280992855402i

0.056441730723125-0.962280992855402i

14

z=[0:

0.1:

10];

x=z.*sin(3*z);

y=z.*cos(3*z);

plot3(x,y,z,'linewidth',2)

gridon

15.

[x,y]=meshgrid(-2:

.1:

2,-2:

.1:

2);

z=x.^2.*exp(-x.^2-y.^2);

surf(z);

16z1=0.05*x-0.05*y+0.1;

holdon

surf(z1)

holdoff

gridon

17

clear,clc

[x,y]=meshgrid(-2:

0.1:

2);

z=x.^2.*exp(-x.^2-y.^2);

z1=0.05*x-0.05*y+0.1;

mesh(x,y,z);

holdon

mesh(x,y,z1);

holdon

%如果只有一个hold那么就会在onoff之间变换

r0=(abs(z-z1)<=0.01);%只有在z=z1处保留r0=1

x0=r0.*x;

y0=r0.*y;

z0=r0.*z;

plot3(x0,y0,z0,'b*');%这些点不是连续的,因此用标识符

%plot3(x0(r0~=0),y0(r0~=0),z0(r0~=0),'b*');

colormap(gray)

gridon;

holdoff

18

f1=@(x)x.^3-4*x.^4+3*x.^2-2*x+6

fzeros(f1,3.5)%调用匿名函数的时候可以不加@

fzero(f1,3.5)

ans=

1.2674

>>f=@(x)x.^3-4*x.^4+3*x.^2-2*x+6+x.*sin(x)

>>fzero(f1,3.5)

ans=

1.3209

19

functiony=f31(x)

y=1./((x-2).^2+0.1)-1./((x-3).^4+0.02);

%主程序

x=[0:

0.001:

4];

y=f31(x);

plot(x,y)%orfplot(@f31,[04])

20

>>f4=@(x)x.^3-2.*x.^2.*sin(x)+5.*x.*cos(x)+1./x;

>>x=linspace(0,4,100);

>>y=f4(x);

>>plot(x,y,'k','linewidth',2)

>>gridon

>>x1=fzero(f4,1.5)

x1=

1.5117

>>x2=fzero(f4,3)

X2=

2.6095

21

[t,y]=ode45(@homework21,[0,5],1);

plot(t,y)

functiondy=homework(x,y)

dy=x^2/y-x*cos(y);

22.

>>s='y=magic(3)';

>>eval(s)

y=

816

357

492

23

forn=3:

5

eval(['y',num2str(n),'=magic(n)'])

end

24

sprintf('%s%22.20f','自然对数底数e=',exp

(1))

ans=

自然对数底数e=2.71828182845904550000

25

A=ones(7,1)*[-3-2-10123]

A=

-3-2-10123

-3-2-10123

-3-2-10123

-3-2-10123

-3-2-10123

-3-2-10123

-3-2-10123

A=[1234]’%A=[1;2;3;4]

B=[A.^0,A.^1,A.^2,A.^3,A.^4]

26

solve('x^3+cos(a)','x')

ans=

(-cos(a))^(1/3)

-1/2*(-cos(a))^(1/3)-1/2*i*3^(1/2)*(-cos(a))^(1/3)

-1/2*(-cos(a))^(1/3)+1/2*i*3^(1/2)*(-cos(a))^(1/3)

subs(x,'a',0.5)

ans=

0.4787+0.8291i

0.4787-0.8291i

-0.9574-0.0000i

roots([100cos(0.5)])

ans=

-0.9574

0.4787+0.8291i

0.4787-0.8291i

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

当前位置:首页 > 表格模板 > 合同协议

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

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