You are on page 1of 7

1

LAB
12/401.
().
Matlab.
,
.
:

.

MATLAB
T
MATLAB, Math Works Inc.,
. MATLAB
, ,
,
, ,
, , . MATLAB
. .
MATLAB ,
- . ,
, ,
, , -
, ,
,
, ,

.
MATLAB,
SIMULINK, ,
,
, SIMULINK

.
, MATLAB
, ,
.

1. Matlab
Matlab Windows
Matlab.

(Command Window)
intro, demo, help help .. >>.
,
, >>.
Matlab
,
. ,
help Enter,
, , . :
help
.
, %
.
.
Matlab ,
".m", Script- . File -> New -> MFile. (Edit Window),
( ). o
:
Matlab ,
M-File.
M-File
( >>) Enter.

2.
Script- (-)
.
.

(
). :
x = 2*sin(pi/2)
:
=
2
,
, Matlab ,
ans. :
12*5
:
ans =
60
, Matlab , ..
Matlab case sensitive . F f,

Matlab
.
,
,
";".

3.
-
-
. ,
, . :
R = [ tan(pi/4)
sqrt(9)
-5 ]

R = 1.0000
3.000
-5.0000
- .
-
- ,
.
:
X = [ 2; -4; 8]

X =
2
-4
8
-
Enter.

- -
. :
Y = R

Y =
1.0000
3.0000
-5.0000

Matlab ( )
.
, .

X Y, n- ,

x y .
i =1

X Y,


S = X * Y
e
S =
-50
.* .
= X .* Y

E =
2
-12
-40
./ ,
.^ ..

:
Z = zeros(1, 4)

Z =
0
0
0

:
I = ones(1, 4)

I =
1
1
1

:
x = 1:8

x =
1
2
3
4
5
6
7
8

4.
Matlab e ,
.
. ;
Enter. :
A = [ 6
1
2;
-1
8
3;
2
4
9 ]


=
6
1
-1 8
2
4

2
3
9


: .
. ,
, :
r3 = A(3, : ),

r3 =
2
4
9
, A A(:, 2).


B,
AB. ,
.
(*), (/) . \ B e 1 B ,
A / B e AB 1 .
. 1

4 2
2 10

4 6

AX = B , -:
10 x1 10
12 x2 = 32 ,
16 x3 16

X .
X,
(\).
:
:
A = [ 4
-2
-10;
2
B = [ -10;
32;
-16];
X = A\B
:
X =
2.0000
4.0000
1.0000

10

-12;

-4

-6

16];

. 2
AX = B .1.
X, inv .
:
:
A = [ 4
-2
-10;
2
B = [ -10;
32;
-16];
X = inv(A)*B
e :
X =
2.0000
4.0000
1.0000

10

-12;

-4

-6

16];


m n
(m,n).
:
N = zeros(m,n) mxn
:
E = ones(m,n)

mxn

:
D = diag(x)

x (x - D).

5.
Matlab i
j. :
Z = 10 + j*20

Z =
10.0000 +20.0000i
,
. :

Y = 1/Z

Y =

0.0200 - 0.0400i
e
Z real(Z) imag(Z).

6.
, . ,
y=f(x), X Y:
x = [ 6 3
6
4 4.1 4
5
4 0 0 9
9 4 ];
y = [11 5 5.5 2
3
2 2.5 2 2 12 12 2 2 ];
plot(x,y) , grid
xlabel('x'), ylabel('y'), title(' ')
!

, y1=f1(x), y2=f2(x), y3=f3(x), ... ,
:
plot(x,y1, x,y2, x,y3, )

7.
for, while
if. for , end, ,
, . , :
for i = 1:n

end
n .
while ,
, .
if, elseif else ,
.
6 4 ,
.

==
~=
<
<=
>
>=

-
-
-
-


&

~

xor

You might also like