>> A=[1,2;3,4],B=[0,2;4,5] A = 1 2 3 4 B = 0 2 4 5 >> C=A>=B C = 1 1 0 0 >> D=A==B D = 0 1 0 0 >> A~=B ans = 1 0 1 1
>> x=-3:5;L=abs(x)>2;y=x(L) y = -3 3 4 5 >> x x = -3 -2 -1 0 1 2 3 4 5 >> L L = 1 0 0 0 0 0 1 1 1 >>
>> a=[16 2 3 13;5 11 0 8;9 7 6 12;4 14 -1 2] a = 16 2 3 13 5 11 0 8 9 7 6 12 4 14 -1 2 >> a(1:3,3) ans = 3 0 6 >> b=a(1:3,:) b = 16 2 3 13 5 11 0 8 9 7 6 12 >> x=(-1:0.2:1) x = 1 至 7 列 -1.0000 -0.8000 -0.6000 -0.4000 -0.2000 0 0.2000 8 至 11 列 0.4000 0.6000 0.8000 1.0000 >> z=[x,sin(x)] z = 1 至 7 列 -1.0000 -0.8000 -0.6000 -0.4000 -0.2000 0 0.2000 8 至 14 列 0.4000 0.6000 0.8000 1.0000 -0.8415 -0.7174 -0.5646 15 至 21 列 -0.3894 -0.1987 0 0.1987 0.3894 0.5646 0.7174 22 列 0.8415 >> c=magic(4) c = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 >> c(:,3)=[] c = 16 2 13 5 11 8 9 7 12 4 14 1 >> k=find(A<=3) 未定义函数或变量 'A'。 是不是想输入: >> k=find(a<=3) %单下标从上到下,从左到右 k = 5 9 10 12 16 >> [s,t]=find(a<=3) s = 1 1 2 4 4 t = 2 3 3 3 4 >> I=(a<=3) I = 0 1 1 0 0 0 1 0 0 0 0 0 0 0 1 1 >> a(I) ans = 2 3 0 -1 2 >> B=a(abs(a-2)<=1) B = 2 3 2
>> A=[1,3,5;2,4,6;3,5,9] A = 1 3 5 2 4 6 3 5 9 >> B=[1,3,5;2,4,6;1,1,1] B = 1 3 5 2 4 6 1 1 1 >> dB=det(B),nA=inv(A) dB = 0 nA = -1.5000 0.5000 0.5000 -0.0000 1.5000 -1.0000 0.5000 -1.0000 0.5000 >> rref([A,B]) ans = 1 0 0 0 -2 -4 0 1 0 2 5 8 0 0 1 -1 -2 -3 >> c=ones(3),[V,D]=eig(C) c = 1 1 1 1 1 1 1 1 1 未定义函数或变量 'C'。 >> C=ones(3),[V,D]=eig(C) C = 1 1 1 1 1 1 1 1 1 V = 0.4082 0.7071 0.5774 0.4082 -0.7071 0.5774 -0.8165 0 0.5774 D = -0.0000 0 0 0 -0.0000 0 0 0 3.0000 >> cT=(A+i*B)',T=(A+i*B).',rT=A' cT = 1.0000 - 1.0000i 2.0000 - 2.0000i 3.0000 - 1.0000i 3.0000 - 3.0000i 4.0000 - 4.0000i 5.0000 - 1.0000i 5.0000 - 5.0000i 6.0000 - 6.0000i 9.0000 - 1.0000i T = 1.0000 + 1.0000i 2.0000 + 2.0000i 3.0000 + 1.0000i 3.0000 + 3.0000i 4.0000 + 4.0000i 5.0000 + 1.0000i 5.0000 + 5.0000i 6.0000 + 6.0000i 9.0000 + 1.0000i rT = 1 2 3 3 4 5 5 6 9