MATLAB Commands
MATLAB Commands
>> clear
>> (1+sqrt(5))/2
ans =
1.618033988749895
GoldenRatio =
1.618033988749895
2.
>> x = [0 pi/2 pi/4 pi/6 pi 2*pi]
x =
0 1.570796326794897 0.785398163397448
0.523598775598299 3.141592653589793 6.283185307179586
>> a = cos(x)
a =
b =
0 1.000000000000000 0.707106781186547
0.500000000000000 0.000000000000000 -0.000000000000000
c =
1.0e+16 *
0 1.633123935319537 0.000000000000000
0.000000000000000 -0.000000000000000 -0.000000000000000
3.
>> r = [1 2 3 4]
r =
1 2 3 4
Area =
4.
>> a = [0:2:10]
a =
0 2 4 6 8 10
b =
0 2.500000000000000 5.000000000000000
7.500000000000000 10.000000000000000
b =
0 2 4 6 8 10
>> c=a+b
c =
0 4 8 12 16 20
ans =
1 6
5.
>> clear
>> X= [0 : 0.3 : 2*pi]
X =
Columns 1 through 6
0 0.300000000000000 0.600000000000000
0.900000000000000 1.200000000000000 1.500000000000000
Columns 7 through 12
Columns 13 through 18
Columns 19 through 21
>> Ya = cos(X)
Ya =
Columns 1 through 6
Columns 7 through 12
Columns 13 through 18
Columns 19 through 21
>> Yb = sin(X)
Yb =
Columns 1 through 6
0 0.295520206661340 0.564642473395035
0.783326909627483 0.932039085967226 0.997494986604054
Columns 7 through 12
Columns 13 through 18
Columns 19 through 21
>> plot(X,Ya,X,Yb)
6.
>> A = [1,2,3,4;11,12,13,14;21,22,23,24]
A =
1 2 3 4
11 12 13 14
21 22 23 24
>> size(A)
ans =
3 4
>> B= A(3, :)
B =
21 22 23 24
>> D = A(:,2)
D =
2
12
22
>> A=A'
A =
1 11 21
2 12 22
3 13 23
4 14 24