8. .
. . - (-) |
. |
M-File.
1. M-File, M-File 0 1 0.1.
M-File - MatLab, . MatLab -, .
1. , -, , .
M-File
function f=myfun1(x)
f=exp(-x)*sqrt((x^2+1)/(x^4+0.1));
function , -. , . myfun1 , f. , , . f.
. Save Save as , File name myfun1. , - .
, sin, cos, exp , .
y=myfun1(1)
y =
0.4960
, .
2. -
function f=myfun2(x)
f=exp(-x).*sqrt((x.^2.+1)./(x.^4.+0.1));
, , :
>> x=1:5; y=myfun2(x)
y =
0.4960 0.0754 0.0175 0.0047 0.0014
>>
2. , 1 . -0.5 0.5 0.05.
.
- . - .
|
|
3. -, -
function r=radius(x,y,z)
r=sqrt(x^2+y^2+z^2)
(2;3;5)
r=radius(2,3,5)
r =
6.1644
3. , . 1; 0,5; 2 0,1; 0,01; 0,001.
. , , -, -. - , feval, .
4. -,
function p=cos2(fname,x)
p=cos(feval(fname,x))^2;
( MatLab ).
p1=pr('sin',0)
p1 =
p2=pr('myfun1',1)
p2 =
0.7735
:
4. , , , . 1, 2, 0,001,
5. , , . 4 . , 4 5 .
1 | 1 | 1 | |
2 | 2 | 2 | |
1 | 1 | 1 | |
2 | 2 | 2 | |
1 | 1 | 1 | |
2 | 2 | 2 |