.


:




:

































 

 

 

 





MatLab , , . MatLab - . , , , , , . , MatLab 1 x 1, . , . , .

. MatLab , - -. , , . , - - . , MatLab , .

 

, :

, ;

, -.

3.1-12
>>a=[0.2; -3.9; 4.6] a = 0.2000 -3.9000 4.6000 >>b=[7.6; 0.1; 2.5] b = 7.6000 0.1000 2.5000 >>u=[0.1 0.5 -3.7 8.1] u = 0.1000 0.5000 -3.7000 8.1000 >>v=[5.2 9.7 3.4 0.2] v = 5.2000 9.7000 3.4000 0.2000 >>

 

, , Workspace whos.

length(), .

3.1-13
>>L=length(a) L = >>

 

- "+" "". -.

- - . * . MatLab - - , - - ( ), - - ( , ). dot(), - cross():

3.1-14
>>s=dot(a, b) s= 1.2630e+001 >>c=cross(a, b) c= -1.0210e+001 3.4460e+001 2.9660e+001 >>

 

- '. , ' - . cross() dot() , , . , , c=cross(a,b'), c -.

MatLab . , - .* ( ). , , . , a b, , :

3.1-15
>>c=a.* b c = 1.5200 -0.3900 11.5000 >>

 

- ./ ( ). , .\ ( ) , a./b b.\a . a , b, - .^. - - - .' ( ). - ' .' . , , . , , a*2, , a, .

, , sin(), cos() . . , , :

3.1-16
>>q=sin([0 pi/2 pi]) q = 0 1.0000 0.0000 >>

 

, , α, , -, , f=(α*sin(α)+α^2)/(α+1) α sin(α ). , α - , . sin(α), , ( ) . α , , , α*α.

MatLab .

3.1-17
>>f=(a.*sin(a)+a.^2)./(a+1); >>

 

, . - -:, , .

3.1-18
>>x=-1.2:0.5:1.8 x = -1.2000 -0.7000 -0.2000 0.3000 0.8000 1.3000 1.8000 >>f=(x.*sin(x)+x.^2)./(x+1) f = -12.7922 3.1365 0.0997 0.1374 0.6744 1.2794 1.7832 >>

 

, , . , , :

3.1-17
>>n=-3:4 n = -3 -2 -1 0 1 2 3 4 >>

 

, - -.

.

3.1-18
>>x=10:-2:0x = 10 8 6 4 2 0>>sin(x)= -0.5440 0.9894 -0.2794 -0.7568 0.9093 0 >>

 

, .

3.1-19
>>y=[2 3 5 8 3 9];>>x*y??? Error using ==> * Inner matrix dimensions must agree. >>
, () .
3.1-20a
>>x*y'ans = 112>>

 

-:

3.1-20b
>>y=[2;3;5;8;3;9] >>

MatLab , . 5.3-6.

. 3.1-6

s=sum(a) a
p=prod(a) a
m=max(a) a
[m,k]=max(a) k a
m=min(a) a
[m,k]=min(a) k a
m=mean(a) a
a1=sort(a) a
[a1,ind]=sort(a) ind 1 length(a),

 

help datafun, help. , , . .

, . MatLab, . , . , y

3.1-21
>>s=y(1)+y(3); >>

 

end, y(end) y(length(v)) .

, ( ).

3.1-22
>>h=10; >>h(2)=20; >>h(4)=40 h = 10 20 0 40 >>

 

, h , h=1 ( ). h, ( h(3)) .

. , :

3.1-23
>>z=[0.2 -3.8 7.9 4.5 7.2 -8.1 3.4]; >>znew=z(3:6) znew = 7.9000 4.5000 7.2000 -8.1000 >>

. prod() z :

3.1-24
>>p=prod(z(2:6)) >>

 

. , :

.3.1-25
>>ind=[3 5 7]; >>znew=z(ind) znew = 7.9000 7.2000 3.4000 >>

z :

3.1-26
>>ind=2:2:length(z); >>s=sum(z(ind)) >>

 

 

. , z.

3.1-27
>>znew=[z(1:4) z(6:end)] znew = 0.2000 -3.8000 7.9000 4.5000 -8.1000 3.4000 >>

 

-;, :

=[v1;v2;v3 ], v1, v2, v3 - .

. . 3.1-7.

. 3.1-7

zeros F=zeros(4,5) F=zeros(3) F=zeros([3 4])
eye ( ) I=eye(5,8) I=eye(5) I=eye([5 8])
ones , E=ones(3,5) E=ones(6) E=ones([2 5])
rand , , (0,1) R=rand(5,7) R=rand(6) R=rand([3 5])
randn , , , N=randn(5,3) N=randn(9) N=randn([2 4])
diag 1) , D=diag(v) 2) k ( k , ), length(v)+abs(k) D=diag(v,k) 3) d=diag(A) 4) k- d=diag(A,k)

 

.

3.1-28
>>Z=zeros(3,5)Z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0>>A=[1 2 3 4; 5 6 7 8; 9 10 11 12]; % (43)A = 1 2 3 4 5 6 7 8 9 10 11 12 >>

 

.

3.1-29
% "" ʖ , % [1 2 3 4]>>K=[A;1 2 3] K = 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 >>

, , 1, :

3.1-30
>>x=[1 2 3 4]x = 1 2 3 4>>c=1.256c = 1.2560 >>

 

, . .

 

1) A B:

.3.1-31
>>B=[2 5; 6 4; 6 5; 8 3]B = 2 5 6 4 6 5 8 3>>C=A*BC = 64 40 152 108 240 176 >>

 

2) ".":

3.1-32
>>A1=[1 3 4 6; 9 7 4 0; 8 6 3 9];>>2=A.*A12 = 1 6 12 24 45 42 28 0 72 60 33 108>>

3) (" "):

3.1-33
>>a1=[A;x]a1 = 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 >>

 

.

4) ( - '):

3.1-34
>>Bt=B'Bt = 2 6 6 8 5 4 5 3 >>

5) ( ), :

3.1-35
>>A(:,2)=[ ] % A = 1 3 4 5 7 8 9 11 12 >>

6) :

3.1-36
>>y=A(3,3) % 3- 3- y = 12>> % >> A(5) % , % > ans = 7

7) :

, ( ):

3.1-37
>>% 3- , >>% >>y=A(3,:) y = 9 11 12 >>% 3- 1 2 3 .

 

, , ( 1):

3.1-38
>>x=0:5 % = (0 1 2 3 4 5)x = 0 1 2 3 4 5 >>x=0:0.1:0.5 % = (0 0,2 0,3 0,4 0,5)x = 0 0.1000 0.2000 0.3000 0.4000 0.5000 >>

 

, . . , :

( ): A=[0.7 2.5 9.1 <Enter>. ( >> ). , <Enter>. :

3.1-39a
>>A=[0.7 -2.5 9.1 8.4 0.3 1.7 -3.5 6.2 4.7] A = 0.7000 -2.5000 9.1000 8.4000 0.3000 1.7000 -3.5000 6.2000 4.7000 >>

 

, -, . -, , ,

:

2.3.1-39b
>>B=[6.1 0.3; -7.9 4.4; 2.5 -8.1] B = 6.1000 0.3000 -7.9000 4.4000 2.5000 -8.1000 >>

, , -, . ,

:

3.1-40
>> C=[[0.4; 0.1] [-7.2; -2.1] [5.3; -9.5]] C = 0.4000 -7.2000 5.3000 0.1000 -2.1000 -9.5000 >>

 

whos A, B C . , , , double array:

3.1-41
>>whos A B C Name Size Bytes Class A 3x3 72 double array B 3x2 48 double array C 2x3 48 double array >>

 

size() , , , :

3.1-42
>>s=size(B) s = 3 2 >>

 

+, -. * , .

, , . - ' . ^.

MatLab . .

, , :

3.1-43
>>c1=A(2:3,2) c1 = 0.3000 6.2000 >> r1=A(1,1:3) r1 = 0.7000 -2.5000 9.1000 >>

() , r1=A(1,1:3) r1=A(1,:) . end, : A(1,2:end). , , , , .

T :

T , :

3.1-44
>>c1=A(2:3,2) c1 = 0.3000 6.2000 >>

 

. , , :

A.*B, A./B - ;

A.^p - , p - ;

A.^B - A , B;

A.' - ( A' A.' ).

, "" . 90o rot90():

3.1-45
>>Q=[1 2;3 4] Q = 1 2 3 4 >>R=rot90(Q) R = 2 4 1 3 >>

 

, , , . , .

MatLab , , sqrtm() . , , :

2.3.1-46
>>K=[3 2; 1 4]; >> S=sqrtm(K) S = 1.6882 0.5479 0.2740 1.9621 >>S*S ans = 3.0000 2.0000 1.0000 4.0000 >>

 

expm(). funm() .

. , , , sum() -, , :

3.1-47
>>M=[1 2 3; 4 5 6; 7 8 9] M = 1 2 3 4 5 6 7 8 9 >>s=sum(M) s = 12 15 18

 

sum() 2, . sum():

3.1-48
>>s=sum(sum(M)) s = 45 >>

 

MatLab . :

M1, M2, M3 M4 M

.

, M , , , M1, M2, M3 M4. , MatLab M :

 

2.3.1-49
>>M=[M1 M2; M3 M4]; >>

 

. . Array Editor.

Array Editor ( ) . , , (. 3.1-4). . Array Editor.
. 3.1 -4 d.

 

(Save), (Cut) ( ) , (Paste) (Print). . , .

3.1 -4.

 





:


: 2016-11-24; !; : 635 |


:

:

, .
==> ...

1696 - | 1549 -


© 2015-2024 lektsii.org - -

: 0.07 .