Basic of MATLAB Command 01
MATLAB COMMAND
##1
>> X=[0 0.1*pi 0.2*pi 0.4*pi 0.5*pi 0.6*pi 0.7*pi 0.4*pi 0.8*pi]
X = 0 0.3142 0.6283 1.2566 1.5708 1.8850 2.1991 1.2566 2.5133
>>X(3)
ans = 0.6283
>> Y=sin(X)
Y = 0 0.3090 0.5878 0.9511 1.0000 0.9511 0.8090 0.9511 0.5878
>>Y(5)
ans = 1
>>X(1:5)
ans = 0 0.3142 0.6283 1.2566 1.5708
>> X(7:end)
ans = 2.1991 1.2566 2.5133
>>Y(3:-1:1)
ans = 0.5878 0.3090 0
>>X([8 2 9 1])
ans = 1.2566 0.3142 2.5133 0
>>Y([1 1 3 4 2 2])
ans = 0 0 0.5878 0.9511 0.3090 0.3090
>> X=(0:0.1:1)*pi
X = 0 0.3142 0.6283 0.9425 1.2566 1.5708 1.8850 2.1991 2.5133 2.8274 3.1416
>> X=linspace(0,pi,1)
X = 3.1416
>>logspace(0,2,2)
ans = 1 100
>>logspace(0,2,1)
ans = 100
##2
A=[1:7]
A = 1 2 3 4 5 6 7
>> F=[1 1 1 1;1 1 1 1;1 1 1 1]
>> B=[linspace(1,7,5)]
B = 1.0000 2.5000 4.0000 5.5000 7.0000
>>A(1:7)
ans =1 2 3 4 5 6 7
>> a=1:5,B=1:2:9
a = 1 2 3 4 5
B = 1 3 5 7 9
C=[B A]
C = 1 3 5 7 9 1 2 3 4 5 6 7
>> C=[1;2;3;4;5]
C =
1
2
3
4
5
>> A=1:5
A =
1 2 3 4 5
>> B=A'
B =
1
2
3
4
5
>> W=B'
W =
1 2 3 4 5
>> C=A'
C =
1
2
3
4
5
>> D=complex(A,A)
D =
1.0000 + 1.0000i 2.0000 + 2.0000i 3.0000 + 3.0000i 4.0000 + 4.0000i 5.0000 + 5.0000i
>> E=D'
E =
1.0000 - 1.0000i
2.0000 - 2.0000i
3.0000 - 3.0000i
4.0000 - 4.0000i
5.0000 - 5.0000i
>> F=D'
F =
1.0000 - 1.0000i
2.0000 - 2.0000i
3.0000 - 3.0000i
4.0000 - 4.0000i
5.0000 - 5.0000i
>> [1 2 3 4 5 6 7 8 9 10 11 12]
ans =
1 2 3 4 5 6 7 8 9 10 11 12
G=[1 2 3 4; 5 6 7 8; 9 10 11 12]
G =
1 2 3 4
5 6 7 8
9 10 11 12
>> G-2
ans =
-1 0 1 2
3 4 5 6
7 8 9 10
>> 2*G-1
ans =
1 3 5 7
9 11 13 15
17 19 21 23
>> 2*G/5-1
ans =
-0.6000 -0.2000 0.2000 0.6000
1.0000 1.4000 1.8000 2.2000
2.6000 3.0000 3.4000 3.8000
>> G
G =
1 2 3 4
5 6 7 8
9 10 11 12
H=[1 1 1 1;2 2 2 2;3 3 3 3]
H =
1 1 1 1
2 2 2 2
3 3 3 3
>> G+H
ans =
2 3 4 5
7 8 9 10
12 13 14 15
>> 2*G-H
ans =
1 3 5 7
8 10 12 14
15 17 19 21
>> G/H
ans =
0 0 0.8333
0 0 2.1667
0 0 3.5000
>>1./G
ans =
1.0000 0.5000 0.3333 0.2500
0.2000 0.1667 0.1429 0.1250
0.1111 0.1000 0.0909 0.0833
F =
1 1 1 1
1 1 1 1
1 1 1 1
>> F./G
ans =
1.0000 0.5000 0.3333 0.2500
0.2000 0.1667 0.1429 0.1250
0.1111 0.1000 0.0909 0.0833
>> G.^2
ans =
1 4 9 16
25 36 49 64
81 100 121 144
>> G.^-1
ans =
1.0000 0.5000 0.3333 0.2500
0.2000 0.1667 0.1429 0.1250
0.1111 0.1000 0.0909 0.0833
No comments