, .
.
<↑> <↓>
Command History.
Command History - , . < Enter> (. 4).
- Command History , ( ). <Shift>+<↑>, <Shift>+<↓>. Command History . Copy Windows. Command Window . Paste . < Enter>.
.
Windows, .
. MATLAB . . ( Warning) , .
( ???) MATLAB .
() .
F sym (F=sym()). F .
pretty(F) F , . . pretty(F) .
clc
>> clc
MATLAB >> .
, , Command History Workspase. , clc.
MATLAB , , clc.
help.
|
|
3. , MATLAB . double ( ). , MATLAB , .
MATLAB single, ( 4 ). .
: int8, uint8, int16, uint16, int32, uint32, int64, uint64. 8, 16, 32 64 . u 0 .
, double, , .
,
>> x=int32(3.2)
int32.
MATLAB . , File│Save Workspace As
6.0, MATLAB Workspace, View => Workspace . Workspace , , whos.
, Workspace . , , . . , Open () Array Editor.
4. Workspace Array Editor .
Array Editor , , . .
0×0, Array Editor.
>> M=[]
M =
[]
5. , . (): , , , , , MATLAB . , , :
;
.
.
|
|
, , , <'> ():
>> disp(A')
dot:
>> s=dot(x,y)
s =
. MATLAB cross, .
det(B) │ B │ B.
>> d=det(B)
inv(B) -1, B. B , .
, sqrtm. expm logm.
, MATLAB . <.*> ( ), <./>, <.\>, <.^>. .
6. MATLAB ( ) . < / >, < \ >, . B/A B*inv(A)
X*A = B,
A \ B inv(A)*B
A*X = B.
:
< \ >.
:
= b,
A =, b =, =
, - - .
- b:
>> =[1 3 0;-2 -2 5;1 0 -5]
=
1 3 0
-2 -2 5
1 0 -5
>> b=[-2;10;-9]
b =
-2
-9
, , (│ A │ = det (A) ≠ 0). :
>> disp(det(A))
-5
. < \ >:
>> x=\b
x =
-1
x1 = 1, x2 = -1, x3 = 2 :
>> disp(A*x)
-2.0000
10.0000
-9.0000
- .
7. <:> () , ( ). . :
>> V=-0.1:0.3:1.4
, :
>> V1=[1 2 3];V2=[4 5 6];
>> V=[V1 V2]
V =
1 2 3 4 5 6
. W , , V :
>> ind=[5 2 1 3];
>> W=V(ind)
W =
5 2 1 3
. .
:
>> P=[-1 0.1 2.2 3.4 5.6 3.1 6.8 9.7 5.5];
|
|
>> P(3:7)=0
8. MATLAB . :
zeros(M,N) M×N c :
>> zeros(3,4)
ones(M,N) M×N c :
>> ones(3,4)
eye(M,N) M×N c :
>> eye(3,4)
rand(M,N) M×N , 0 1:
>> rand(3,4)
randn(M,N) M×N , () , 1:
>> randn(3,4)
M (M=N):
>> eye(3)
rot90 90o :
>> Q=[1 2;3 4]
>> R=rot90(Q)
D=diag(V) , - V;
D=diag(V,k) k ( k , ), length(V)+abs(k);
d=diag(A) A d;
d=diag(A,k) k - A d.
9. , (), . - A1, A2,,AN , , A= [ A1,A2,,AN ]. , - , : A= [ A1;A2;,AN ].
10. MATLAB , . , M-. function d=rad(x,y,z)
% d=sqrt(x^2+y^2+z^2) - (x;y;z)
d=sqrt(x^2+y^2+z^2);
M-- .
M-- function. M- . M- , ( ) . rad. ( .m) . M-- Save (), Editor () rad.m. , M- x, y, z. d, .
- , %. help. M- rad.m ; help rad.
11. MATLAB - . . - , - :
|
|
function noout(a,b), function [v,u]=noin, function noarg().
MATLAB - , global.
- rad3 :
function [d,d2]=rad3
global x y z
d2=x^2+y^2+z^2;
d=sqrt(d2);
:
>> global x y z
>> x=2;y=3;z=4;
>> [m,n]=rad3
m =
5.3852
n =
, -, x, y, z d rad.m, . M-- , . MATLAB , M-- , , , .
12. , , . . , 1 (True ), 0 (False ). 4.1.
== | Eq | |
~= | Ne | |
< | Lt | |
> | Gt | |
<= | Le | |
>= | Ge |
4.3.
& | And | |
| | Or | |
Xor | ||
~ | Not |
(), < > ().
MATLAB :
1. < () >.
2. < .' >, < ' >, < ^ >, < .^ >.
3. <+>, <>, <~>.
4. ( ) < * >, < / >, < \ >, < .* >, < ./ >, < .\ >.
5. <+> <>.
6. <, <=, >, >=, ==, ~=.
7. < & >.
8. <|>.
13. for , . for :
for var = b1:b2:b3
( )
End
var () , b1 b3 b2 ( b2 , 1). , . <, >, <; > <Enter>. end. , var b3.
, , while. while , .
- polsum, :
function s=polsum(x)
s=0;
k=1;
while x(k)>0
s=s+x(k);
k=k+1;
end
14. if-elseif-else. ( elseif else) - possum, , 2:
, if-elseif-else. elseif , . , , , if-elseif-else , end. else . , else end, , .
|
|