matlab程序设计语言答案doc.docx

上传人:b****6 文档编号:8763913 上传时间:2023-05-14 格式:DOCX 页数:64 大小:82.51KB
下载 相关 举报
matlab程序设计语言答案doc.docx_第1页
第1页 / 共64页
matlab程序设计语言答案doc.docx_第2页
第2页 / 共64页
matlab程序设计语言答案doc.docx_第3页
第3页 / 共64页
matlab程序设计语言答案doc.docx_第4页
第4页 / 共64页
matlab程序设计语言答案doc.docx_第5页
第5页 / 共64页
matlab程序设计语言答案doc.docx_第6页
第6页 / 共64页
matlab程序设计语言答案doc.docx_第7页
第7页 / 共64页
matlab程序设计语言答案doc.docx_第8页
第8页 / 共64页
matlab程序设计语言答案doc.docx_第9页
第9页 / 共64页
matlab程序设计语言答案doc.docx_第10页
第10页 / 共64页
matlab程序设计语言答案doc.docx_第11页
第11页 / 共64页
matlab程序设计语言答案doc.docx_第12页
第12页 / 共64页
matlab程序设计语言答案doc.docx_第13页
第13页 / 共64页
matlab程序设计语言答案doc.docx_第14页
第14页 / 共64页
matlab程序设计语言答案doc.docx_第15页
第15页 / 共64页
matlab程序设计语言答案doc.docx_第16页
第16页 / 共64页
matlab程序设计语言答案doc.docx_第17页
第17页 / 共64页
matlab程序设计语言答案doc.docx_第18页
第18页 / 共64页
matlab程序设计语言答案doc.docx_第19页
第19页 / 共64页
matlab程序设计语言答案doc.docx_第20页
第20页 / 共64页
亲,该文档总共64页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

matlab程序设计语言答案doc.docx

《matlab程序设计语言答案doc.docx》由会员分享,可在线阅读,更多相关《matlab程序设计语言答案doc.docx(64页珍藏版)》请在冰点文库上搜索。

matlab程序设计语言答案doc.docx

matlab程序设计语言答案doc

一、实验结果:

1、程序:

3*3的单位阵:

>>a=eye(3)

a=

100

010

001

15*8的单位阵:

>>a=eye(15,8)

a=

10000000

01000000

00100000

00010000

00001000

00000100

00000010

00000001

00000000

00000000

00000000

00000000

00000000

00000000

00000000

3*3的全1阵:

>>a=ones(3)

a=

111

111

111

15*8的全1阵

>>a=ones(15,8)

a=

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

11111111

3*3的全0阵:

>>a=zeros(3)

a=

000

000

000

15*8的全0阵:

>>a=zeros(15,8)

a=

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

00000000

3*3的均匀分布随机阵([-1,1]之间):

>>r=2*rand(3,3)-1

r=

0.62940.8268-0.4430

0.81160.26470.0938

-0.7460-0.80490.9150

3*3的正态分布随机阵(均值为1,方差为4):

>>r=2*randn(3,3)+1

r=

6.53892.45080.5901

-1.69980.87390.7517

7.06982.42953.9794

15*8的均匀分布随机阵([-1,1]之间):

>>r=2*rand(15,8)-1

r=

Columns1through5

0.5844-0.90770.41870.39820.2321

0.9190-0.80570.50940.7818-0.0534

0.31150.6469-0.44790.9186-0.2967

-0.92860.38970.35940.09440.6617

0.6983-0.36580.3102-0.72280.1705

0.86800.9004-0.6748-0.70140.0994

0.3575-0.9311-0.7620-0.48500.8344

0.5155-0.1225-0.00330.6814-0.4283

0.4863-0.23690.9195-0.49140.5144

-0.21550.5310-0.31920.62860.5075

0.31100.59040.1705-0.5130-0.2391

-0.6576-0.6263-0.55240.85850.1356

0.4121-0.02050.5025-0.3000-0.8483

-0.9363-0.1088-0.4898-0.6068-0.8921

-0.44620.29260.0119-0.49780.0616

Columns6through8

0.55830.37840.5498

0.86800.49630.6346

-0.7402-0.09890.7374

0.1376-0.8324-0.8311

-0.0612-0.5420-0.2004

-0.97620.8267-0.4803

-0.3258-0.69520.6001

-0.67560.6516-0.1372

0.58860.07670.8213

-0.37760.9923-0.6363

0.0571-0.8436-0.4724

-0.6687-0.1146-0.7089

0.2040-0.7867-0.7279

-0.47410.92380.7386

0.3082-0.99070.1594

15*8的正态分布随机阵(均值为1,方差为4):

>>r=2*randn(15,8)+1

r=

Columns1through5

1.06702.04011.6151-1.72342.6521

-1.66740.9599-1.51421.91014.0540

3.25500.9305-0.7309-0.69741.9338

1.7004-0.59630.64690.33020.5806

0.40193.03742.58282.10562.2504

1.04580.7336-1.66403.07821.3665

0.4760-0.4291-3.6597-1.2353-1.0595

-2.50043.7028-1.89823.52132.8984

0.42870.55051.66702.32031.6141

-0.6627-0.17811.78270.86431.2703

-0.95840.41251.90340.60962.0305

-1.3128-0.69590.73940.56481.5228

-0.0671-1.24031.36740.3938-0.8830

-3.00536.05200.04771.04610.6753

2.92854.31102.72401.10260.7079

Columns6through8

-0.06400.1107-1.1334

4.36420.68812.8675

-0.75151.55211.7006

0.03240.47770.9420

-0.42401.88681.3649

-1.34841.7838-2.1301

0.6155-1.50140.8309

0.4519-0.89594.2079

4.0601-0.48221.1967

0.5020-0.01561.0827

-1.12840.3588-0.4683

4.20691.02490.9384

3.4694-5.05841.4647

0.54070.08601.8528

-2.01233.48490.2544

2、a矩阵:

>>v1=[8-72];

>>v2=[53];>>c=fliplr(diag(v1))+fliplr(diag(v2,-1))

c=

008

0-75

230

b矩阵:

>>v1=[258];457

>>v2=[407];

>>c=diag(v1)+fliplr(diag(v2))

c=

204

050

708

3、>>a=5-round(100*rand(50,2))/10

a=

2.30001.0000

4.6000-1.2000

-1.70003.5000

0.70001.2000

0.50003.4000

-1.1000-2.6000

4.4000-3.7000

1.80001.5000

-2.7000-1.9000

-2.00002.1000

3.7000-0.3000

3.7000-3.3000

4.1000-1.0000

4.90001.6000

0.80002.0000

-1.60000.5000

-2.20000.8000

-0.30001.4000

3.9000-0.6000

-1.3000-2.4000

3.70000.8000

3.70000.7000

4.00003.8000

3.60004.8000

3.30002.1000

3.00001.8000

1.8000-1.5000

1.8000-4.6000

2.8000-4.4000

2.50000.4000

-3.90002.6000

-2.0000-2.6000

-0.6000-2.6000

3.2000-2.4000

2.9000-2.4000

4.20003.9000

-4.1000-1.8000

-2.10000.4000

-0.60002.9000

1.90004.0000

3.3000-3.2000

-1.20003.2000

-4.90003.4000

3.3000-1.7000

2.4000-3.9000

1.0000-0.2000

4.3000-2.0000

-1.80003.5000

1.0000-4.5000

-4.8000-0.4000

4、脚本:

x=[-pi:

pi/180:

pi]

y1=sin(x)

y2=cos(x)

结果:

x=

Columns1through5

-3.1416-3.1241-3.1067-3.0892-3.0718

Columns6through10

-3.0543-3.0369-3.0194-3.0020-2.9845……Columns356through360

3.05433.07183.08923.10673.1241

Column361

3.1416

y1=

Columns1through5

-0.0000-0.0175-0.0349-0.0523-0.0698

Columns6through10………Columns356through360

0.08720.06980.05230.03490.0175

Column361

0.0000

y2=

Columns1through5

-1.0000-0.9998-0.9994-0.9986-0.9976

Columns6through10

-0.9962-0.9945-0.9925-0.9903-0.9877……Columns356through360

-0.9962-0.9976-0.9986-0.9994-0.9998

Column361

-1.0000

5、A=rand(10,10)

b=A>0.6

[i,j,v]=find(b)

c=sum(v)

A=

Columns1through5

0.69810.19040.48200.82440.5944

0.66650.36890.12060.98270.0225

0.17810.46070.58950.73020.4253

0.12800.98160.22620.34390.3127

0.99910.15640.38460.58410.1615

0.17110.85550.58300.10780.1788

0.03260.64480.25180.90630.4229

0.56120.37630.29040.87970.0942

0.88190.19090.61710.81780.5985

0.66920.42830.26530.26070.4709

Columns6through10

0.69590.71840.15370.24070.3445

0.69990.96860.28100.67610.7805

0.63850.53130.44010.28910.6753

0.03360.32510.52710.67180.0067

0.06880.10560.45740.69510.6022

0.31960.61100.87540.06800.3868

0.53090.77880.51810.25480.9160

0.65440.42350.94360.22400.0012

0.40760.09080.63770.66780.4624

0.82000.26650.95770.84440.4243

b=

Columns1through9

100101100

100101101

000101000

010000001

100000001

010000110

010100100

000101010

10110001

c=

37

6、A=randn(10,10)

b=-0.5

[i,j,v]=find(b)

c=sum(v)

A=

Columns1through5

-0.1132-0.6264-0.5933-0.98700.3277

1.63600.24950.40130.7596-0.2383

-0.4251-0.99300.9421-0.65720.2296

0.58940.97500.3005-0.60390.4400

-0.0628-0.6407-0.37310.1769-0.6169

-2.02201.80890.8155-0.30750.2748

-0.9821-1.07990.7989-0.13180.6011

0.61250.19920.12020.59540.0923

-0.0549-1.52100.57121.04681.7298

-1.1187-0.72360.4128-0.1980-0.6086

Columns6through10

-0.73710.10170.38932.2272-1.0322

-1.74992.78730.7512-0.06921.3312

0.9105-1.16671.7783-0.5073-0.4189

0.8671-1.85431.22310.2358-0.1403

-0.0799-1.1407-1.28330.24580.8998

0.8985-1.0933-2.32900.0700-0.3001

0.1837-0.43360.9019-0.60861.0294

0.2908-0.1685-1.8356-1.2226-0.3451

0.1129-0.21850.06680.31651.0128

0.44000.54130.0355-1.34290.6293

b=

Columns1through9

011101000

000001000

010100101

000100100

010010110

100000110

110000001

000000011

010000000

110010001

Column10

1

0

0

0

0

0

0

0

0

0

c=

29

7、a=[0.530.971.051.340.782.200.67]

b=[0.340.670.450.890.120.670.24]

ifand(a<1,b<=0.5)

disp('a<1andb<=0.5')

elseifand(a<1,b>0.5)

disp('a<1andb>0.5')

elseifand(a>=1,b<=0.5)

disp('a>=1andb<0.5')

elseifand(a>=1,b>0.5)

disp('a>=1andb>0.5')

else

disp('error')

end

a=

0.53000.97001.05001.34000.78002.20000.6700

b=

0.34000.67000.45000.89000.12000.67000.2400

error

8、A=[0.530.971.05;1.230.671.56;0.341.980.36];

b=A>1;

c=A.*b;

[i,j,v]=find(c)

v=

1.2300

1.9800

1.0500

1.5600

9、A=rand(100,3)+99.1

b=A>100;

c=A.*b;

[i,j,B]=find(c)

A=

100.087999.731299.8829

99.270499.455199.7938

99.3578100.097099.1098……

99.544099.225799.6882

99.160099.408999.4662

99.966799.826199.9068

B=

100.0879

100.0828

100.0569……

100.0870

100.0386

100.0419

10、A=[12030;00000;18050;34050;64020]

b=any(A)

[i,j,v]=find(1-b)

A(:

j)=[]

B=A'

c=any(B)

[i,j,v]=find(1-c)

B(:

j)=[]

A=B'

A=

12030

00000

18050

34050

64020

A=

123

185

345

642

1、程序:

x=0:

pi/50:

2*pi

k=[1265176101];

x(k)=[];

figure

(1)

subplot(2,2,1)

plot(x,sin(x)),gridon

subplot(2,2,2)

plot(x,cos(x)),gridon

subplot(2,2,3)

plot(x,tan(x)),gridon

subplot(2,2,4)

plot(x,cot(x)),gridon

2、程序:

x=0.01:

.01:

1;

y1=log10(x)

y2=exp(x)

figure

(1)

plot(x,y1,'k-',x,y2,'k--'),gridon

legend('\ity=log_{10}(x)','\ity=e^x')

title('y=log_{10}(x)andy=e^x')

ylabel('y'),xlabel('x')

 

3、程序:

x=0:

pi/40:

4*pi

figure

(1)

subplot(2,1,1)

plot(x,sec(x)),gridon

title('sec(x)')

ylabel('y'),xlabel('x')

subplot(2,1,2)

plot(x,csc(x)),gridon

title('csc(x)')

ylabel('y'),xlabel('x')

 

4、程序:

x=(1:

.1:

10)

y=exp(x+5)+x.^3

semilogx(x,y,'k-')

title('y=e^(x+5)+x.^3')

ylabel('y'),xlabel('x')

5、程序:

(1)[x,y]=meshgrid(-3:

.15:

3);

z=peaks(x,y)

x1=x(1,:

plot(x1,z),gridon

 

(2)x=0:

pi/50:

2*pi;

y1=sin(x);y2=cos(x);

figure

(1)

plot(x,y1,'k-',x,y2,'k--'),gridon

text(pi,0.05,'\leftarrowsin(\alpha)')

text(pi/4-0.05,0.05,'cos(\alpha)\rightarrow')

title('sin(\alpha)andcos(\alpha)')

xlabel('\alpha'),ylabel('sin(\alpha)?

cos(\alpha)')

6、程序:

x=-3:

.1:

3

y1=2*x+5

y2=x.^2-3*x+1

figure

(1)

subplot(2,1,1),plot(x,y1)

axis([12510])

title('y1=2x+5')

ylabel('y'),xlabel('x')

subplot(2,1,2),plot(x,y2)

axis([-1005])

title('x.^2-3x+1')

ylabel('y'),xlabel('x')

二、

(1)、程序:

autumn

cmap=colormap;

L=length(cmap);

x=[1:

L];

y=x'*ones(size(x));

figure

(1)

bar(x(1:

2),y(1:

2,:

));

title('autumn')

colormap('autumn')

(2)、程序bon

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

当前位置:首页 > 工程科技 > 兵器核科学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2