.


:




:

































 

 

 

 


, . A(1:k, j) k j




.

MATLAB

 

 

 

2008

32.973.26.-018.2

12

 

. MATLAB: 190100.62 230103 ( ) / .. . : , 2008. 31 .

 

 

MATLAB, , , , , MATLAB. .

MATLAB

1

1.

..................................... 19

2.

............................... 21

3.

, , ....................................................23

4.

... 25

2

5.

...................................

6.

........

7.

. ....................

MATLAB

Matrix Laboratory. MATLAB, The MathWorks, Inc., . , . MATLAB:

;

;

, , ;

, ;

;

, .

MATLAB - , , . , - .

MATLAB 6.1 - ( - MATLAB 6.5).

MATLAB - . , MATLAB . , -. - MATLAB Application Toolboxes, MATLAB, .

MATLAB 6.1. MATLAB 6.1 - , , -, Microsoft Word, Excel .

MATLAB , , . MATLAB (. 1).

 

.1

 

. 2.

 

(. 2) : (, , , , , , .) MATLAB; ; Web Web- Internet; / - ( -, ); .

... ( ), , (. 3), .

MATLAB -: -; -; ; ; ; .

MATLAB , , . Enter MATLAB , , . ; (-).

.

>> a=2

a =

>> b=4;

>> =a+b

=

, MATLAB , .

, MATLAB. MATLAB, :

- , ( ).

MATLAB, . who ( ) whos ( ) . : , ( MAT-), ; ( ). , ( : clear).

load save.

.

>> save

Saving to: matlab.mat

>> load

Loading from: matlab.mat

>> save my.mat

>> load my.mat

>> save my2

>> load my2

, MATLAB.

, MATLAB , . , , 9.

/ - MATLAB, , edit edit < -> -.

/ : -; -; - ; ; ; ; ; / ; .

GUIDE , .

. -. , , MATLAB. . MATLAB , , , MATLAB, M- (*.m). M- (/ -).

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

File MatLab New M-file. M - (. 10). -

. 10

a b, fun1.m. , .

   
>> a = 7.5; b = 3.342; c = (a+b)/2 c = 5.4210 >> fun1 c = 5.4210

 

. Figure. fun2.m. >> fun2 Figure (. 11).

 

fun2.m
x=[0: 0.1: 7]; f=exp(-x); subplot(1, 2, 1) plot(x, f) g=sin(x); subplot(1, 2, 2) plot(x, g)

. 11

 

 

M-: - - . fun1 fun2 -.

-:

1. , .

2. .

3. .

4. - - .

5. / (/) F5.

-:

1. MATLAB ( , ).

2. .

3. , .

1) , .

: function y = funa(x,a), function - , -; y - ; funa - ; x, - .

, : function [x, y, z] = funb(t, p, r).

, , . - , - 31 ; ; , .

2) % . , help <_>.

3) - , .

.

 

. , , .

- : : what; M- fact.m: type fact.

MATLAB. - - -, MATLAB . , , /, , , . MATLAB, -.

MATLAB , . - double, char, sparse, uint8, cell, struct. , MATLAB .

: (double) (char) . , MATLAB .

MATLAB , , . 10.

MATLAB , . 11. .

, array () . , MATLAB ( array ).

, , . , , . , double , - numeric.

MATLAB. , MATLAB , . .

, , , MATLAB - , . , ans - , ; pi - c : pi=3.141592653589793e+000; inf - ; NaN - - : 0/0, inf/inf.

-, , MATLAB/toolbox/matlab/elmat online-.

.

1) , i j, (i, j). , , , , MATLAB .

, . A(1:k, j) k j.

: : A(:,3).

, 5.0, end. , A(:, end) .

3) . , , . - [], : B = [A A+32; A+48 A+16], - .

4) MATLAB , , -. () . -. A(3) ; (7) - .

MATLAB. . , . MATLAB . :

v .

v .

v .

:

>> D=sqrt(A(2))+2*B(1)

D =

4.8284

. MATLAB 6 :

<

<=

>

> =

==

~ =

. MATLAB : & - ; | - ; ~ - .

, , .

( ) : 1) if, else elseif ; 2) switch, case otherwise ; 3) while , ; 4) for . end, , . , MATLAB.

: . L , . , L, .

L , Figure (, ).

, :

 

: 1) , 2) plot. >> x=0:0.01:2; >> y=sin(x); >> plot(x,y)
: hold on plot(x1,y1,x2,y2,,xn,yn). >> x=0:0.01:2; >> y1=sin(x); y2=cos(x); >> plot(x,y1) >> hold on >> plot(x,y2) >> plot(x,y1,x,y2)
n : subplot (< >, < >, < >) lot. <> >> subplot(1,2,1); >> plot(x1,y1) >> subplot(1,2,2); >> plot(x2,y2) <>

 

, , . , - , .

plot(x1,y1,'s1',x1,y2,'s2',), 1(1), 2(2),... s1, s2,... . . , : '-' ; '--' ; ':' - ; '-.' ; : 'k' ; 'r' ; 'b' ; : '.' ; '+' ; '*' ; '' ..

.

>> plot(x,y,'o') %

>> plot(x,y,'r+-') % -

>> plot(x,y,'+r-') %

>> plot(x,y,'r-',x,y,'ko')

>> plot(x1,y1,'b',x2,y2,'k+')

, , , .

(, ) get. , get . , hPlot line :

>> x=0:0.1:3;

>> y=sin(x);

>> hPlot=plot(x,y);

>> get(hPlot)

Color = [0 0 1]

EraseMode = normal

LineStyle = -

LineWidth = [0.5]

Marker = none

. , (LineWidth), 0,5; lor : [0 0 1] (RGB-, ), . , , , , L . . , .

, . . L , . L . .

L, . is([min, max, min, max]), , , , . , .

. . set axes. , , . gca. .

>> hAxes=gca;

>> set (hAxes,'xtick',[1.5 1.75 2.0 2.25 2.5])

, ( ) .

, grid on .

xlabel, ylabel, title text. xlabel , label - .

, text, : text (x,y,'some text'), x,y , . , , . \ ( ). . , newline.

title ('some text'), TeX.

, , . . , s [0.5 0.8 0.5]. :

>> hAxes=gca;

gca s. s, . , , s, , , .

:

>> set (hs, '1', [ 0.5 0.8 0.5]);

:

>> FigureColor = [ 0.8 0.5 0.5]; hFigure = gcf;

>> Set (hFigure, 'lr', FigureColor);

gcf figure, , .

MATLAB . , , atch. .

, . , .

L . 1, 1 z=f(x,y) z1. ( ) 2, 2 z1. , () (1,1,z1), (2,2,z2),, (N,N,zN) N , . L .

( ). : (-), (-). , - . - z=f(x,y) . Z.

, plot3

>> lot3(, , Z)

X, Z - , .

L u, v , : [X, ] = meshgrid(u,v) ( . ).

, lot3 ( line) , , z. - , , , X, Z. , X, , Z; - . .

L , . mesh, surf surfl. surface.

mesh L - (- wireframe mesh) . - , . , ( ) - -. -, . , ( - ) , mesh .

, . , , hidden off, . , - . hidden on.

, - . mesh surf: surf (X, , Z). , () , () ( ) .

surfl surf . , . . , ( ), , , , - -.

, , : axis([xmin xmax ymin ymax zmin zmax]), text, xlabel, ylabel, zlabel ..

. . , : ( az) ( el). z . .

mesh, surf surfl, az=-37.5º, el=30º. view([az,el]), .

, , MATLAB , . , ( , ), MATLAB () . ( ).

, , . MATLAB .

, MATLAB (, , , ), 30-. L , ( ) Windows WAVE (*.wav).

Symbolic Math Toolbox. L , , .

L , . () . (- - tlb) L .

L - L, . , ( Partial Differential Equations lb), (Statistics lb) (ptimization lb), (Image Processing lb; Wavelet Toolbox) .

Symbolic Math lb, L . Waterloo l Software, Canada, L . L, . Symbolic Math lb , .

Symbolic Math lb , . .

Symbolic Math lb - digits vpa. , . vpa Variable Precision Arithmetic, .

.

>> digits(30); vpa(pi)

ans = 3.14159265358979323846264338328

- 30 , ans sym object. Symbolic Math lb .

y1=y; s2=['n=' num2str(n)]; hText=text(1.5, 1.5^2*n-1, s2); set(hText,'FontSize',[14]); end

. () , Figure , , . num2str(x), x :

>> x=-2:0.1:2;

title('{\itf(x)=x^{n}}');

xlabel('x');

ylabel('y');

hFigure=gcf;

set(hFigure,'Color',[1 1 1]);

hText=text;

set(hText,'FontSize',[18]);

for n=2:4

y=x.^n;

hold on

hPlot=plot(x,y);

set(hPlot,'Color',[1.8/n 0.7 0.5]);

set(hPlot,'LineWidth',2);

if n~=2

for i=1:length(y)

s='';

if y(i)==y1(i)

hold on

plot(x(i),y(i),'ko');

s=['(' num2str(x(i)) ',' num2str(y(i)) ')'];

hText=text(x(i),y(i)+2, s); set(hText,'FontSize',[16]);

end

end

end

y1=y; s2=['n=' num2str(n)];

hText=text(1.5, 1.5^2*n-1, s2); set(hText,'FontSize',[14]);

end

 

 

. 12

1

MATLAB , , .

1. Enter MATLAB , , . ; (-).

>> a=2

a =

>> b=4;

>> =a+b

=

, MATLAB , .

2. :

>> r =(1+sqrt(5))/2

r =

1.6180

3. (2,4):

>> Z=zeros(2,4)

Z =

0 0 0 0

0 0 0 0

4. . .

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

A =

1 2 3

4 5 6

7 8 9

5. :

>> A.^2

ans =

1 4 9

16 25 36

49 64 81

6. :

>> A=[1 2 3;4 5 6;7 8 9]; B=2*A; C=A+B

C =

3 6 9

12 15 18

21 24 27

7. , cos :

>> cos(C)

ans =

-0.9900 0.9602 -0.9111

0.8439 -0.7597 0.6603

-0.5477 0.4242 -0.2921

8. :

>> x=2;y=(sin(2*x)-tan(7.8*x^2)/cos(3*x^4))*exp(-2*x)

y =

-0.0201

 

2





:


: 2015-10-27; !; : 512 |


:

:

, .
==> ...

1515 - | 1404 -


© 2015-2024 lektsii.org - -

: 0.226 .