Contents
% Ratkaisuja tehtäviin 2 19.5.2010 HA
Teht 1 a)
format compact 2:2:20 % tai 2*(1:10)
ans =
Columns 1 through 6
2 4 6 8 10 12
Columns 7 through 10
14 16 18 20
ans =
Columns 1 through 6
2 4 6 8 10 12
Columns 7 through 10
14 16 18 20
b)
10:-2:-10 fliplr(-10:2:10)
ans =
Columns 1 through 6
10 8 6 4 2 0
Columns 7 through 11
-2 -4 -6 -8 -10
ans =
Columns 1 through 6
10 8 6 4 2 0
Columns 7 through 11
-2 -4 -6 -8 -10
c)
format rational 1./(1:10) % tai pitemmin: ones(1,10)./(1:10) format % palataan oletusformaattiin
ans =
Columns 1 through 6
1 1/2 1/3 1/4 1/5 1/6
Columns 7 through 10
1/7 1/8 1/9 1/10
ans =
Columns 1 through 6
1 1/2 1/3 1/4 1/5 1/6
Columns 7 through 10
1/7 1/8 1/9 1/10
d)
format rational
(0:9)./(1:10)
ans =
Columns 1 through 6
0 1/2 2/3 3/4 4/5 5/6
Columns 7 through 10
6/7 7/8 8/9 9/10