MATLAB Command Window Page 1
>> 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 =
1×0 empty double row vector
>> 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) pi)
d = (sqrt(4) pi)
Invalid expression. Check for missing multiplication operator, missing or unbalanced
delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses.
>> d = (sqrt(4) 3)
d = (sqrt(4) 3)
Invalid expression. Check for missing multiplication operator, missing or unbalanced
delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses.
>> d = [sqrt(4) pi]
d =
2.0000 3.1416
>> linspace(10,50,20)
MATLAB Command Window Page 3
ans =
Columns 1 through 13
10.0000 12.1053 14.2105 16.3158 18.4211 20.5263 22.6316 24.7368
26.8421 28.9474 31.0526 33.1579 35.2632
Columns 14 through 20
37.3684 39.4737 41.5789 43.6842 45.7895 47.8947 50.0000
>> y = 4:2:20
y =
4 6 8 10 12 14 16 18 20
>> [sqrt(10) 4 pi^2; 11 sqrt(5)/pi sin20; 6540 1 2]
Unrecognized function or variable 'sin20'.
Did you mean:
>> [sqrt(10) 4 pi^2; 11 sqrt(5)/pi sin 20; 6540 1 2]
Error using sin
Not enough input arguments.
>> [sqrt(10) 4 pi^2; 11 sqrt(5)/pi sin (20); 6540 1 2]
Error using sin
Not enough input arguments.
>> [sqrt(10) 4 pi^2; 11 sqrt(5)/pi sine(20); 6540 1 2]
Unrecognized function or variable 'sine'.
Did you mean:
>> [sqrt(10) 4 pi^2; 11 sqrt(5)/pi sin(20); 6540 1 2]
ans =
1.0e+03 *
0.0032 0.0040 0.0099
0.0110 0.0007 0.0009
6.5400 0.0010 0.0020
>> linspace (0,15,1)
ans =
15
>> linspace (0,1,15)
ans =
Columns 1 through 13
MATLAB Command Window Page 4
0 0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000
0.5714 0.6429 0.7143 0.7857 0.8571
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 =
0.9575 0.9706 0.8003
0.9649 0.9572 0.1419
0.1576 0.4854 0.4218
>> 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 = ones (2,2)
x =
1 1
1 1
MATLAB Command Window Page 5
>> size(x)
ans =
2 2
>> b = [1 2 3;4 5 6];
>> size(b)
ans =
2 3
>> rand(size(b))
ans =
0.8491 0.6787 0.7431
0.9340 0.7577 0.3922
>> 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
>> b = [1 7 12; 2 14 15; 16 18 19];
>> d = 3 * a
d =
6 21 36
39 12 15
>> c = 0.5 * b
MATLAB Command Window Page 6
c =
0.5000 3.5000 6.0000
1.0000 7.0000 7.5000
8.0000 9.0000 9.5000
>> d (2,3)
ans =
15
>> c (3,2)
ans =
>> r = [4:9:12]
r =
>> r = (4,9,12)
r = (4,9,12)
Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.
>> r = linspace(4,9,12)
r =
4.0000 4.4545 4.9091 5.3636 5.8182 6.2727 6.7273 7.1818
7.6364 8.0909 8.5455 9.0000
>> p = (8:0.5:13)
p =
8.0000 8.5000 9.0000 9.5000 10.0000 10.5000 11.0000 11.5000
12.0000 12.5000 13.0000
>> b
b =
1 7 12
2 14 15
16 18 19
>> b (3,1) == c (3,1)
MATLAB Command Window Page 7
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
>> e (3:4, 1:2)
ans =
1 9
4 8
>> b (2:3, 1:3)
ans =
2 14 15
16 18 19
>> b(7)
ans =
12
>> b(5)
ans =
14
>> e(6)
ans =
>>