.


:




:

































 

 

 

 


- -

MatLab , , . MatLab, , -, -. - m (M-), MatLab. , -.

MatLab M-, New M-file , File New M-file. . - , (. 5.1):

5.1. -

x=[-1:0.01:1];

y=exp(x);

plot(x,y)

grid on

title(' ')

. , , , [1] <Shift> , <PageUp>, <PageDown> View Evaluate Selection ( <F9>). , , . , M- , , , , , .

, M-, myprog.m, Tools Run, M- ( ) <Enter>, , MatLab. M- MatLab. myprog .

MatLab 5.3 File Set Path Path Browser ( ). Current Directory . , , .

MatLab 6.x Current Directory . , Current Directory View . , .

, M-, , , M-. - , . . . , whos. , - . , :

a=[0.1 0.4 0.3 1.9 3.3];

-, bar(), a (, -).

- - , , , -, . M-, -, , MatLab. function, , - . . 5.2 - .

5.2. - mysum

function c=mysum(a,b)

c=a+b;

. , MatLab M- -, .. mysum.m. - M-, -! , mysum.m - mysum :

s=mysum(2,3)

s =

- mysum :

a 2;

b 3;

a b c;

c s .

, c=a+b - mysum c . -, , .

MatLab - M-. sin : sin(x) y=sin(x), ans, y. mysum . , mysum .

, - . - , . 5.3 - quadec, .

5.3. -

function [x1,x2]=quadeq(a,b,c)

D=b^2-4*a*c;

x1=(b+sqrt(D))/(2*a);

x2=(b-sqrt(D))/(2*a);

quadeq , :

[r1,r2]=quadeq(1,3,2)

r1 =

r2 =

, - quadec , . .

- , - :

function noout(a,b), function [v,u]=noin, function noarg()

- - MatLab, MatLab ( , , , [2]). , . - myfun . (. 5.4) , myfun .

5.4. - myfun

function y=myfun(x);

y=exp(-x).*(sin(x)+0.1*sin(100*pi*x));

. , 0.01, plot:

x=[0:0.01:1];

y=myfun(x);

plot(x,y)

, . 5.1, , , , . , 0.01 plot , . . MatLab fplot plot, . fplot -, , : fplot(' -', [a,b]). fplot:

figure

fplot('myfun',[0,1])

, (. 5.1, ).

) )

. 5.1.

- plot ( 0.05) fplot :

1. . 2. .

3. . 4. .

5. . 6. .

 

7. . 8. .

9. .

10. .

- .

1. -, .

2. -, .

3. -, .

4. -, .

5. -, .

6. -, .

7. -, 1,1 .

8. -, () x y .

9. -, , .

10. -, , .


[1] , .

[2] MatLab .



<== | ==>
.. | . . .
:


: 2016-09-06; !; : 969 |


:

:

, .
==> ...

1525 - | 1412 -


© 2015-2024 lektsii.org - -

: 0.018 .