You are on page 1of 7

MATLAB

. MATLAB ( ) MathWorks
(http://www.mathworks.com). 1984 .
MATLAB 5 [10]. MATLAB http://www.matlab.ru.
MATLAB . , ,
m- (< >.m). m-. MATLAB m- , , ,
. m- , / m- MATLAB.
. :
,
m
End
,

- ;
- ;
- ;
- , .

help .
, ,
help <>.
. (), .
. .
.
: a+i*b a+j*b.
format.
. . ,
=[1 2 3 ]
=[1
2
3]
=[ 1 2 3
456]
=[ 1 2 3;
456]
=[ 1 2 3; 4 5 6 ]
: A(i), B(i,j).
. .
111

.
:
+

, :
pi
eps
realmax
realmin
i,j

- ;
- ;
- ;
- ;
- .

:
xp(x)
log(x)
lg10(x)
sin(x)
cos(x)
tan(x)
bs(x)
angl(x)
sqrt(x)
real()
imag(x)
conj(x)
round(x)
fix(x)
sign(x)
rem(x,)
mod(x,y)

- ;
- ;
- ;
- ;
- ;
- ;
- x;
- ;
- x;
- x;
- x;
- - ;
- ;
- ;
- ;
- x ;
- .

:
rand - (0,1) ;
randn -
.
.
zeros(n,m)
ones(n,m)
eye(n,m)
rand(n,m)

- ;
- ;
- ;
- .

:
+*

/\
inv(A)

- , , ;
- , ;
- ;
- ;
112

eig()
det(A)
rank(A)
pol()
trace(A)
kron(A,B)
norm
size(A)

- ;
- ;
- ;
- ;
- ;
- ;
- ;
- .

. ,
A.*B - .
:
expm(A) - ;
logm() - ;
sqrtm(A) - .
: Ax = b
=[1 2
3 4 ];
b=[ 5
6 ];
x=inv(A)*b x=A\b
:
=[ ] - ;
=[ ] - A B , ,
A=[A
B]
=[ ]
A(n1:n2,m1:m2), ,
A(1:10,5:8)
B(3,2:7)

A(n1:n2,:)=[ ]
B(:,m1:m2)=[ ]
p(x) = a0 xn + a1 xn1 + + an
. ,
a=[1 2 3 4]
a(x) = x3 + 2x2 + 3x + 4. :
113

conv(a,b)
deconv(a,b)
polyval(p,x)
polyvalm(p,X)
roots(p)
l(r)
polyfit(x,y,n)
polyder(p)

- ;
- ;
- (x);
- p(X);
- ;
- ,
r;
-
;
- .

MATLAB. m-.
. :
%
r=input( r=);
disp( 1=);
l= 2*pi*r;
disp(l);
%.
help < >.m
echo on , echo off . ;
. pause .
:
==

<

>

<=

>=

:
& AND
| OR
NOT
.
:
if < >
<>
end
if < >
<>
else
<>
end

114

if < >
<>
elseif < >
<>
else
<>
end

switch <>
case < 1>
<>
case < 2>
<>
..................
otherwise
<>
end

.
for
for < >:<>:< >
<>
end
, . ,
i=0;
for x=0:0.1:100
i=i+1;
y(i)=sin(x);
end;

x=0:0.1:100;
y=sin(x);
while
while < >
<>
end
115

.
plot
mesh
contour
title
xlabel
ylabel
zlabel
grid
axis
text
gtext
figure
close
subplot

- ;
- ;
- ;
- ;
- x;
- y;
- z;
- ;
- ;
- ;
- ;
- ;
- ;
- .


x=0:0.1:10;
y=sin(x);
plot(x,y);
.
dir
cd
type
delete
what
who
clear
save
load
edit

- ;
- ;
- m-;
- ;
- m- ;
- ;
- ;
- mat-;
- mat-;
- m-;

. m-.
.
function < >=< >( )
<>
< >=<>

global < >
, .
116

. ode23, ode45 . ,
x 1 = x2 ,
x 2 = x1 x2
[t0 , t1 ] c x1 (0) = 1, x2 (0) = 1

t0=0;
t1=5;
x0=[ 1
-1 ];
[T,X]=ode45(model,[t0 t1],x0);
plot(T,X);
model.m
function f=model(t,x)
f=[ x(2)
-x(1)-x(2) ];
. MATLAB
, , ,
- , ,
,
, .

117

You might also like