MATLAB练习题2
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
>> A=rand(3,5)
A =
0.8147 0.9134 0.2785 0.9649 0.9572
0.9058 0.6324 0.5469 0.1576 0.4854
0.1270 0.0975 0.9575 0.9706 0.8003 >> [n,m]=find(A>0.5)
n =
1
2
1
2
2
3
1
3
1
3
m =
1
1
2
2
3
3
4
4
5
5
>> a=find(A>0.5)
a =
1
2
4
5
8
9
10
12
13
15
>> a=[2,-2;-1,2],b=[1,-1;0,2],c=[1;-2],d=eye(2)
a =
2 -2
-1 2
b =
1 -1
0 2
c =
1
-2
d =
1 0
0 1
>> a. result=a+b;
??? Warning: Struct field assignment overwrites a value with class "double".
See MA TLAB 7.0.4 Release Notes, Assigning Nonstructure V ariables As Structures Displays Warning for details.
>> b. result=a*d;
Undefined function 'mtimes' for input arguments of type 'struct'.
>> c. result=a .*d;
Undefined function 'times' for input arguments of type 'struct'.
>> result=a*c;
Undefined function 'mtimes' for input arguments of type 'struct'.
>> result=a .*c;
Undefined function 'times' for input arguments of type 'struct'.
>> result=a\b;
Undefined function 'mldivide' for input arguments of type 'struct'.
>> g. result=a .\b
Undefined function 'ldivide' for input arguments of type 'struct'.
>> result=a.^b
Undefined function 'power' for input arguments of type 'struct'.
>> result=a+b
Undefined function 'plus' for input arguments of type 'struct'.
>> A=[-2,5,1,3,4,-1;2,-1,-5,-2,6,4;-1,6,-4,-5,3,-1;4,6,-6,-4,-2,-2;-3,6,4,2,-6,4;2,4,4,4,5,-4] A =
-2 5 1 3 4 -1
2 -1 -5 -2 6 4
-1 6 -4 -5 3 -1
4 6 -6 -4 -2 -2
-3 6 4 2 -6 4
2 4 4 4 5 -4
>> B=[0;1;-6;10;-6;-2]
B =
1
-6
10
-6
-2
>> X=A\B
X =
0.5001
-0.2240
-2.7296
2.6073
-0.9339
-0.7637
>> a=[2,-2;-1,2],b=[1,-1;0,2],c=[1;-2],d=eye(2)
a =
2 -2
-1 2
b =
1 -1
0 2
c =
1
-2
d =
1 0
0 1
>> result=a+b
result =
3 -3
-1 4
>> result=a .*d
result =
2 0
0 2
>> result=a*c
result =
6
-5
>> result=a .*c
Error using .*
Matrix dimensions must agree.
>> result=a.*c
Error using .*
Matrix dimensions must agree.
>> result=a\b
result =
1.0000 1.0000
0.5000 1.5000
>> result=a.\b
result =
0.5000 0.5000
0 1.0000
>> result=a.^b
result =
2.0000 -0.5000
1.0000 4.0000
>> p=[3 0 1 1.5 0 0.5 0];s=[5 -8 -10 1 2 -2]; >> [c,r]=deconv(p,q)
Undefined function or variable 'q'.
>> [c,r]=deconv(p,s)
c =