.


:




:

































 

 

 

 


MATLAB.




MATLAB

MATLAB.

MATLAB.

MATLAB , , . MATLAB , .

 

MATLAB

MATLAB .

1. Command Window ( ).

Command Window . , , , . >>. , 1+2

>> 1 + 2

Enter.

ans =

>> |

ans.

=.

>> z = 1.25 /3.11

z =

0.40193

Command Window . , .

, . :

DesktopDesktop LayoutDefault.

( ).

 

:

EditClear Command Window.

( ).

 

2. Workspace ( ).

, . , - . .

 

3. Current Folder ( ).

. , , , , ..

 

4. Command History ( ).

, , , Command History. , Command History, , , . . .

 

MATLAB

, . MATLAB :

File () ;

Edit () ;

Window () ;

Help () MATLAB.

 

MATLAB.

:

New file () ;

Open file () ;

Cut () ;

Copy () ;

Paste () ;

Undo () ;

Redo () ;

Simulink Simulink ( MATLAB);

Help () .

 

, ( 4.0193e-001, ), (, 0.040193).

,

( ); ( ).

.

!

>> s = 0.3467819

s =

0.3468

, . , short ( ), . long ( ),

>> format long

>> s

s =

0.34678190000000

Numerical Format

short e ;

long e ;

short g ;

long g ;

 

 

,

>> help format

File () Preferences (). Command Window ( ). Text display ( ), Numeric format ( ) short g, Numeric display ( ) compact. .

 

, , , (15 ). .

MATLAB.

MATLAB :

+,

*, /

^

 

.

 

, = . . .

:

ans ;

eps ;

realmax ;

realmin ;

pi ;

i, j ;

Inf ;

NaN .

 

clear. ,

>> x=3

x =

>> clear x

>> x

??? 'x'.

 

, MATLAB, .

:

sin (x), cos (x), tan (x), cot (x) , , , x;

sec (x), csc (x) , x;

asin (x), acos (x), atan (x), acot (x) , , , x;

exp (x) x;

log (x) x;

log10 (x) x;

log2 (x) 2 x;

pow2 (x) 2 x;

sqrt (x) x;

abs (x) x;

round (x) x ;

fix (x) x ;

floor (x) x ;

ceil (x) x ;

mod (x,y) x y ;

rem (x,y) x y;

sign (x) x.

 

>> exp(2.5)*log(11.3)^0.3 sqrt((sin(2.45*pi)+cos(3.78*pi))/tan(3.3))

ans =

3.2105

:

. , :

  1. , ;
  2. ;
  3. Enter.

>> exp(2.5)*log(11.3)^0.3 + ((sin(2.45*pi)+cos(3.78*pi))/tan(3.3))^2

ans =

121.2446

, , , ,

>> exp(2.5)*log(11.3)^0.3 +...

((sin(2.45*pi)+cos(3.78*pi))/tan(3.3))^2

ans =

121.2446

>> x = sin(1.3*pi)/log(3.4);

>> y = sqrt(tan(2.75)/ cot(2.3));

>> z = (x+y)/(x-y)

z =

-0.013967

; .

 

x y,

>> t = (x*y)^(3/2)

t =

-5.5344e-017 - 0.30128i

 

MATLAB .

:

>> z = 3 + 4i

z =

3.0000 + 4.0000i

- .

>> z1 = z'

z1 =

3.0000 - 4.0000i

 

:

abs (z), angle (z) , , ;

complex( a, b ) :

>> complex(2.3, 5.8)

ans =

2.3 + 5.8i

conj (z) - ;

imag (z), real (z) .

3. .

, , , .

MATLAB [ ]. - ;, ,.

- .

>> x = [1.3; 5.4; 6.9]

x =

1.3

5.4

6.9

- .

>> y = [7.1 3.5 8.2]

y =

7.1 3.5 8.2

:

>> z = y

z =

7.1

3.5

8.2

+ :

>> = x + z

c =

8.4

8.9

15.1

, *.

>> t = 3*x

t =

3.9

16.2

20.7

, ,

>> d = sin(c)

d =

0.8546

0.50102

0.5712

, ,

>> h = x(2)

h =

5.4

,

>> g = [x(2) x(3) x(1)]

g =

5.4 6.9 1.3

- ,

>> t = [x; z]

t =

1.3

5.4

6.9

7.1

3.5

8.2

- ,

>> r = [x y]

r =

1.3 5.4 6.9 7.1 3.5 8.2

 

:

>> w = r(3:5)

w =

6.9 7.1 3.5

: , ,

>> r(3:5)= 0

r =

1.3 5.4 0 0 0 8.2

 

: , , .. ,

>> h = [1:0.2:2]

h =

1 1.2 1.4 1.6 1.8 2

( ).

, ,

>> k = [1:5]

k =

1 2 3 4 5

 

.

.*, .^, ./ , , .

, +, .

/.

, ./.

 

.

, , ,

, ; .

>> v1 = [2 3 4 1];

 

>> v2 = [7 5 6 9];

 

>> p = [4 6 8 10];

 

>> f = [4 2 6];

 

>> s1 = v1.*v2;

 

>> s2 = v1.^2;

 

>> s3 = v1.^v2;

 

>> s4 = v1./v2;

 

>> a = p + 1.2;

 

>> b = p 1.2;

 

>> p = p/2;

 

>> df = 12./f;

 

.

  • length( z ) ;
  • prod( z ) ;
  • sum( z ) ;
  • mean( z ) ;
  • sort( z ) ;
  • max( z ) ;
  • min( z ) .

min max [m, k] = min(z),

( ), .

 

.

,

, ; .

>> z = [3; 2; 1; 4; 6; 5];

 

>> l = length(z);

 

>> p = prod(z);

 

>> s = sum(z);

 

>> q = mean(z);

 

>> M = max(z);

 

>> m = min(z);

 

>> [m, k] = min(z);

 

>> sr = sort(z);

4. .

.

1. -, , - . ,

>> A = [3 1 1; 2 4 3 ]

A =

3 1 1

2 4 3

 

2. , :

>> A = [3 1 1

Enter

2 4 3]

Enter

.

 

3. ,

>> A = [ [3;2] [1;4] [-1;3]]

>> A = [ [3 1;2 4] [-1;3]]

 

:

>> A (2, 3)

ans =

.

  • zeros (m,n) ;
  • eye (n) ;
  • ones (m,n) ;
  • rand (m,n) .

 

.

, ; .

>> O = zeros(3, 6);

 

>> E = eye(4);

 

>> E = eye(8,4);

 

>> EI = ones(3, 8);

 

>> R = rand(3,5)

 

diag (d) d,

>> d = [1; 2; 3; 4];

>> D = diag(d)

D =

1 0 0 0

0 2 0 0

0 0 3 0

0 0 0 4

 

diag( A ) A ,

>> A = [10 1 2; 1 20 3; 2 3 30];

>> d = diag(A)

 

d =

 

.

: .

:

  • M(i,:) i- M;
  • M(:, j) j- M;
  • M(:) M ;
  • M(k:l, n:m) M, , , , ;
  • M(k:l, n:m) = M;
  • M(i,:) = [] i- M;
  • M(:, j) = [] j- M;

 

.

, ; .

>> P = [5 2 1 3; 3 -1 1 2; 1 2 4 8; 3 -1 1 2];

 

>> P1 = P(2:3, 2:3);

 

>> P(2:3,2:3)=0;

 

>> st = P(2,:);

 

>> rt = P(2, 2:end);

 

>> P(1,:) = [];

 

.

.

>> T = zeros(5);

>> T(1,:) = 1;

>> T(end, 3:end) = 1

T =

1 1 1 1 1

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 1 1 1

.

.

+

.

*. .

^.

.*, ./, .^ , , . .^ .

 

 

.

.

, ; .

 

>> A = [2 5 1; 3 4 9];

 

>> B = [1 2 8; 7 3 5];

 

>> S = A+B;

 

>> R = A B;

 

>> A;

 

>> D = A*A;

 

>> D1 = D*3;

 

>> = A.*B;

 

>> Q = A./B;

 

>> P = A.^B;

 

>> D = A.^2;

 

.

  • size( M ) M;
  • sum( M ) M ;
  • sum( M, 2 ) M ;
  • prod( M ) M ;
  • prod( M,2 ) M ;
  • sort( M ) M ;
  • sort( M, 2 ) M ;
  • max( M ) - , M;
  • min( M ) - , M;
  • max (M, [], 2) - , M;
  • min (M, [], 2) - , M;
  • rot90 (M) M ;
  • tril (M) M , ;
  • triu (M) M , ;

 

.

.

, ; .

>> M = [1 2 4; 3 6 4; 2 2 0];

 

>> SZ = size(M);

 

>> S = sum(M);

 

>> S2 = sum(M, 2);

 

>> P = prod(M);

 

>> P2 = prod (M,2);

 

>> mx = max(M);

 

>> mn = min(M);

 

>> MX = max(M, [], 2);

 

>> MN = min(M, [], 2);

.

1, 0, :

 

< (<= " ");

> (>= " ").

 

:

= = ;

& "".

A & B , 1, A B , 0;

| "".

A | B , 1, A B , 0;

~= "" (~= "").

.

,

, ; .

>> A = [1 2 3; 4 0 6; 7 1 9];

 

>> = [1 0 -1; 0 0 -6; 1 2 9];

 

>> D1 = A>B;

 

>> D2 =A<=B;

 

>> D3 = A&B;

 

>> D4 = A==B;

 





:


: 2016-11-18; !; : 2084 |


:

:

,
==> ...

1724 - | 1659 -


© 2015-2024 lektsii.org - -

: 0.332 .