作业.docx
《作业.docx》由会员分享,可在线阅读,更多相关《作业.docx(26页珍藏版)》请在冰豆网上搜索。
作业
本次活动是一个组的同学,把其中一个人眼睛蒙上,其余的人指挥他在教室里走一圈;共进行了四轮,第一轮是一个人,第二轮是两个人,依次增加,一直到最后有20余人参加.本次活动要求指挥者只能是坐在原位,不能跟随参与者走因此,多方的指示声让蒙眼者产生了混乱,从而一圈时间加长了。
人数的增加多也是时间变长的原因之一。
除此之外还有老师突然设置的障碍,更是加重了活动难度。
以上种种原因皆是影响时间长短的重要因素。
为此,我们可以采取以下措施来减少一些麻烦。
首先,我们可以规定最靠近行走者路线的组作为指挥员,最好是一组的两头和中间。
再是,活动中出现了一个失误,20余人分成了三队,女生和男生掉队了,而男生也没接上,总体速度迅速下降。
所以,整个队伍应注意步调协调,前者引导后者,配合后者,争取整队一起快速走一圈,这样的团队速度是最快的,时间是最短的。
a=[13pi3+5i]
a=
Columns1through2
1.00003.0000
Columns3through4
3.14163.0000+5.0000i
>>b=1:
10
b=
Columns1through7
1234567
Columns8through10
8910
>>a={135}
a=
[1][3][5]
>>a=(135)
?
?
?
a=(135)
|
Error:
UnexpectedMATLABexpression.
>>x=linspace(3,6.4)
x=
Columns1through4
3.00003.03433.06873.1030
Columns5through8
3.13743.17173.20613.2404
Columns9through12
3.27473.30913.34343.3778
Columns13through16
3.41213.44653.48083.5152
Columns17through20
3.54953.58383.61823.6525
Columns21through24
3.68693.72123.75563.7899
Columns25through28
3.82423.85863.89293.9273
Columns29through32
3.96163.99604.03034.0646
Columns33through36
4.09904.13334.16774.2020
Columns37through40
4.23644.27074.30514.3394
Columns41through44
4.37374.40814.44244.4768
Columns45through48
4.51114.54554.57984.6141
Columns49through52
4.64854.68284.71724.7515
Columns53through56
4.78594.82024.85454.8889
Columns57through60
4.92324.95764.99195.0263
Columns61through64
5.06065.09495.12935.1636
Columns65through68
5.19805.23235.26675.3010
Columns69through72
5.33545.36975.40405.4384
Columns73through76
5.47275.50715.54145.5758
Columns77through80
5.61015.64445.67885.7131
Columns81through84
5.74755.78185.81625.8505
Columns85through88
5.88485.91925.95355.9879
Columns89through92
6.02226.05666.09096.1253
Columns93through96
6.15966.19396.22836.2626
Columns97through100
6.29706.33136.36576.4000
>>x=linspace(3.6.3)
?
?
?
x=linspace(3.6.3)
|
Error:
UnexpectedMATLABexpression.
>>x=linspace(3,6,3)
x=
3.00004.50006.0000
>>a2=[1,2,3;4,5.6;7.8.9]
?
?
?
a2=[1,2,3;4,5.6;7.8.9]
|
Error:
UnexpectedMATLABexpression.
>>a2=[1,2,3;4,5.6;7,8,9]
?
?
?
Errorusing==>vertcat
CATargumentsdimensionsarenotconsistent.
>>a2=[1,2,3;4,5,6;7,8,9]
a2=
123
456
789
>>ones(6)
ans=
111111
111111
111111
111111
111111
111111
>>zeros(3)
ans=
000
000
000
>>b=reshape(a2,3,3)
b=
123
456
789
>>a=-4:
4
a=
Columns1through7
-4-3-2-1012
Columns8through9
34
>>b=reshape(a,3,3)
b=
-4-12
-303
-214
>>A=[172418;222714;461320];
>>A(:
:
2)=A-10
A(:
:
1)=
172418
222714
461320
A(:
:
2)=
714-9-2
-812-34
-6-4310
>>sub2ind(size(A),2,1,2)
ans=
14
>>A(14)
ans=
-8
b=zeros(3);
>>b(:
)=1:
9
b=
147
258
369
>>IND=[3456]
IND=
3456
>>I,J]=ind2sub(size(b),IND);
?
?
?
I,J]=ind2sub(size(b),IND);
|
Error:
Unbalancedorunexpectedparenthesis
orbracket.
>>[I,J]=ind2sub(size(b),IND);
>>I,J]=ind2sub(size(b),IND);
?
?
?
I,J]=ind2sub(size(b),IND);
|
Error:
Unbalancedorunexpectedparenthesis
orbracket.
>>[I,J]=ind2sub(size(b),IND);
>>
>>[I,J]=ind2sub(size(b),IND)
I=
3123
J=
1222
>>A(:
:
1)=[1025;4187;3263];
>>A(:
:
2)=[3541;2621;4230]
A(:
:
1)=
1025
4187
3263
A(:
:
2)=
3541
2621
4230
>a=2
a=
2
>>b=3
b=
3
>>a+b=
?
?
?
a+b=
|
Error:
Theexpressiontotheleftofthe
equalssignisnotavalidtargetforan
assignment.
c=a+b
c=
5
>>d=a-b
d=
-1
>>c=a*b
c=
6
>>c=a.*b
c=
6
>>ones(3)
ans=
111
111
111
>>c=ones(3)
c=
111
111
111
>>c=1:
9
c=
Columns1through7
1234567
Columns8through9
89
>>c(:
)=
?
?
?
c(:
)=
|
Error:
Expressionorstatementisincomplete
orincorrect.
>>c(:
)=1:
9
c=
Columns1through7
1234567
Columns8through9
89
>>c=ones(3)
c=
111
111
111
>>c(:
)=1:
9
c=
147
258
369
>>b(:
)=-1:
7
?
?
?
InanassignmentA(:
)=B,thenumber
ofelementsinAandB
mustbethesame.
>>b=
-4-12
-303
-214
?
?
?
b=
|
Error:
Expressionorstatementisincomplete
orincorrect.
>>d=c.*b
d=
31221
61524
91827
>>d=c*b
d=
31221
61524
91827
>>b=
-4-12
-303
?
?
?
b=
|
Error:
Expressionorstatementisincomplete
orincorrect.
>>b=
?
?
?
b=
|
Error:
Expressionorstatementisincomplete
orincorrect.
>>a=ones(30
?
?
?
a=ones(30
|
Error:
Expressionorstatementis
incorrect--possiblyunbalanced(,{,or[.
>>a=ones(3)
a=
111
111
111
>>a(:
)=1:
9
a=
147
258
369
>>b=[125;985;553]
b=
125
985
553
>>b=[125;852]
b=
125
852
>>c=a*b
?
?
?
Errorusing==>mtimes
Innermatrixdimensionsmustagree.
>>b=[52;65;82]
b=
52
65
82
>>c=a*b
c=
8536
10445
12354
>>b=[125;852]
b=
125
852
>>c=a.*b
?
?
?
Errorusing==>times
Matrixdimensionsmustagree.
>>b=[52;65;82]
b=
52
65
82
>>c=a.*b
?
?
?
Errorusing==>times
Matrixdimensionsmustagree.
>>d=c.^2
d=
72251296
108162025
151292916
>>a\b
Warning:
Matrixissingulartoworking
precision.
ans=
NaNNaN
Inf-Inf
-InfInf
>>b=[125;985;553]
b=
125
985
553
>>a\b
Warning:
Matrixissingulartoworking
precision.
ans=
NaNNaNNaN
-Inf-Inf-Inf
InfInfInf
b=[123]
b=
123
>>b=[1;2;3]
b=
1
2
3
>>e=d\b
e=
-0.0006
0.0041
>>d=ones(3)
d=
111
111
111
>>d(:
)=1:
9
d=
147
258
369
>>e=d\b
Warning:
Matrixissingulartoworking
precision.
e=
NaN
NaN
NaN
>>e=d\b
Warning:
Matrixissingulartoworking
precision.
e=
NaN
NaN
NaN
>>e=d/b
?
?
?
Errorusing==>mrdivide
Matrixdimensionsmustagree.
>>e=b/d
?
?
?
Errorusing==>mldivide
Matrixdimensionsmustagree.
>>e=b\d
e=
1.00002.28573.5714
>>a=3
a=
3
>>b=4
b=
4
>>c=a&b
c=
1
>>a=0
a=
0
>>c=a|b
c=
1
>>c=a&n
?
?
?
Undefinedfunctionorvariable'n'.
>>c=a&b
c=
0
>>e=~a
e=
1
str1='IlikeMATLAB,'
str1=
IlikeMATLAB,
>>STR2='JAVASCRPIT,ANDME!
'
STR2=
JAVASCRPIT,ANDME!
>>str3=[stristr2]
?
?
?
Undefinedfunctionorvariable'stri'.
>>str3=[str1str2]
?
?
?
Undefinedfunctionorvariable'str2'.
>>str3=[str1STR2]
str3=
IlikeMATLAB,JAVASCRPIT,ANDME!
>>sentence='I''vegotadate!
'
sentence=
I'vegotadate!
>>length(sentence)
ans=
16
>>a=double(sentence)
a=
Columns1through7
733911810132103111
Columns8through14
11632973210097116
Columns15through16
10133
>>b=char(a)
b=
I'vegotadate!
>>a=‘今日事,今日毕';
?
?
?
a=‘今日事,今日毕';
|
Error:
Theinputcharacterisnotvalidin
MATLABstatementsorexpressions.
>>a='今日事,今日毕';
>>out1=class(a)
out1=
char
>>x=chinese+1;
?
?
?
Undefinedfunctionorvariable'chinese'.
>>x=chinese+1;
?
?
?
Undefinedfunctionorvariable'chinese'.
>>x=a+1;
>>out2=ischar(x)
out2=
0
>>departments=[‘ee’;‘cs’;‘econ’]
?
?
?
departments=[‘ee’;‘cs’;‘econ’]
|
Error:
Theinputcharacterisnotvalidin
MATLABstatementsorexpressions.
>>departments=[‘ee’;‘cs’;‘econ’]
?
?
?
departments=[‘ee’;‘cs’;‘econ’]
|
Error:
Theinputcharacterisnotvalidin
MATLABstatementsorexpressions.
>>departments=['ee';'cs';'econ']
departments=
ee
cs
econ
>>departments=char('ee','cs','econ');
>>dept1=departments(1,:
)
dept1=
ee
>>dept2=deblank(dept1)
dept2=
ee
>>len1=length(dept1)
len1=
4
>>len2=length(dept2)
len2=
2
>>departments=char('ee','cs','econ')
departments=
ee
cs
econ
>>str1='today'
str1=
today
>>str1='today';
str2='tomorrow';
str3='today';
out1=strcmp(str1,str2)
out1=
0
>>out2=strcmp(str1,str3)
out2=
1
>>a=[]
a=
[]
>>b=ones(0,5);
>>a,b,c
a=
[]
b=
Emptymatrix:
0-by-5
c=
0
>>whosabc
NameSizeBytesClassAttributes
a0x00double
b0x50double
c1x11logical
>>a=magic(4),a(:
2)=[]
a=
162313
511108
97612
414151
a=
16313
5108
9612
4151
>>a(1,2)=[]
?
?
?
Subscriptedassignmentdimension
mismatch.
>>a(2:
4)=[]
a=
Columns1through7
16310615138
Columns8through9
121
a(1,1)={[143;058;729]};
>>a(1,2)={'AnneSmith'};
>>a(2,1)={3+7i};
>>a(2,2)={-pi:
pi/10:
pi};
>>b{1,1}='JamesBond';
>>b{1,2}=[12;34;56];
>>b{2,1}=pi;
>>b{2,2}=zeros(5);
>>c=[ab]
c=
[3x3double]'AnneSmith''JamesBond'[3x2double]
[3.0000+7.0000i][1x21double][3.1416][5x5double]
>>c=[a;b]
c=
[3x3double]'AnneSmith'
[3.0000+7.0000i][1x21double]
'JamesBond'[3x2double]
[3.1416][5x5double]
>>b=cell(2,3)
b=
[][][]
[][][]
>>whosb
NameSizeBytesClassAttributes
b2x348cell
>>whosb
NameSizeBytesClassAttributes
b2x348cell
>>b(1,3)={1:
3};
>>a
a=
[3x3double]'AnneSmith'
[3.0000+7.0000i][1x21double]
>>celldisp(a)
a{1,1}=
143
058
729
a{2,1}=
3.0000+7.0000i
a{1,2}=
AnneSmith
a{2,2}=
Columns1through9
-3.1416-2.8274-2.5133-2.1991-1.8850-1.5708-1.2566-0.9425-0.6283
Columns10through18
-0.314200.31420.62830.94251.25661.57081.88502.1991
Columns19through21
2.51332.82743.1416
>>cellplot(a)
a{1,2}
ans=
AnneSmith
>>a{:
}
ans=
143
058
729
ans=
3.0000+7.0000i
ans=
AnneSmith
ans=
Columns1through9
-3.1416-2.8274-2.5133-