Test 2
Test 2
>> m = 3 * 5
m =
15
>> m = 3 * k
Unrecognized function or variable 'k'.
>> k = 8 - 2;
>> m
m =
15
>> m = 3*k
m =
18
>> m = m + 1
m =
19
>> y = m/2
y =
9.5000
>> x = (5:20)
x =
5 6 7 8 9 10 11 12 13 14 15 16 17 18
19 20
>> z = (5:20:2)
z =
>> z = (5:2:20)
z =
5 7 9 11 13 15 17 19
>> z = (5:2:20)
MATLAB Command Window Page 2
z =
5 7 9 11 13 15 17 19
>> c = (5:5:20)
c =
5 10 15 20
>> a = (10:5:50)
a =
10 15 20 25 30 35 40 45 50
>> pi
ans =
3.1416
>> 3 + 2
ans =
>> ans + 2
ans =
>> d = (sqrt(4) 3)
d = (sqrt(4) 3)
d =
2.0000 3.1416
>> linspace(10,50,20)
MATLAB Command Window Page 3
ans =
Columns 1 through 13
Columns 14 through 20
>> y = 4:2:20
y =
4 6 8 10 12 14 16 18 20
ans =
1.0e+03 *
ans =
15
ans =
Columns 1 through 13
MATLAB Command Window Page 4
Columns 14 through 15
0.9286 1.0000
>> rand(2)
ans =
0.8147 0.1270
0.9058 0.9134
>> rand(2)
ans =
0.6324 0.2785
0.0975 0.5469
>> rand(3)
ans =
>> rand(5,1)
ans =
0.9157
0.7922
0.9595
0.6557
0.0357
>> x = ones(3,3)
x =
1 1 1
1 1 1
1 1 1
x =
1 1
1 1
MATLAB Command Window Page 5
>> size(x)
ans =
2 2
ans =
2 3
>> rand(size(b))
ans =
>> rand(size(x))
ans =
0.6555 0.7060
0.1712 0.0318
>> b(1,3)
ans =
>> b(2,2)
ans =
>> a = [2 7 12;13 4 5]
a =
2 7 12
13 4 5
d =
6 21 36
39 12 15
>> c = 0.5 * b
MATLAB Command Window Page 6
c =
>> d (2,3)
ans =
15
>> c (3,2)
ans =
>> r = [4:9:12]
r =
>> r = (4,9,12)
r = (4,9,12)
>> r = linspace(4,9,12)
r =
>> p = (8:0.5:13)
p =
>> b
b =
1 7 12
2 14 15
16 18 19
ans =
logical
>> b (3)
ans =
16
>> b (9)
ans =
19
>> b(:,1)
ans =
1
2
16
>> b(3,:)
ans =
16 18 19
>> b (2,:)
ans =
2 14 15
>> b(1:2,1:2)
ans =
1 7
2 14
>> b (1,2,4,5)
Index in position 3 exceeds array bounds (must not exceed 1).
>> e = [1 2; 8 6; 1 9; 4 8]
e =
1 2
8 6
1 9
MATLAB Command Window Page 8
4 8
ans =
1 9
4 8
ans =
2 14 15
16 18 19
>> b(7)
ans =
12
>> b(5)
ans =
14
>> e(6)
ans =
>>