SUNY Geneseo Department of Mathematics
Monday, September 21
Math 230 01
Fall 2015
Prof. Doug Baldwin
linspace
functionlogspace
function (base ten)>> computers = [ 2 3 3 4 2 5 ]
computers =
2 3 3 4 2 5
>> moreComputers = computers * 2
moreComputers =
4 6 6 8 4 10
>> [ 2 : 7 ]
ans =
2 3 4 5 6 7
>> [ 2 : 1/3 : 7 ]
ans =
Columns 1 through 4
2.0000 2.3333 2.6667 3.0000
Columns 5 through 8
3.3333 3.6667 4.0000 4.3333
Columns 9 through 12
4.6667 5.0000 5.3333 5.6667
Columns 13 through 16
6.0000 6.3333 6.6667 7.0000
>> nums = linspace( 0, pi, 1000 )
nums =
Columns 1 through 4
0 0.0031 0.0063 0.0094
…
Columns 997 through 1000
3.1322 3.1353 3.1384 3.1416
>> nums( 500 )
ans =
1.5692
>> linspace( 0, 0, 23 )
ans =
Columns 1 through 7
0 0 0 0 0 0 0
Columns 8 through 14
0 0 0 0 0 0 0
Columns 15 through 21
0 0 0 0 0 0 0
Columns 22 through 23
0 0
>> 0 * [1:23]
ans =
Columns 1 through 7
0 0 0 0 0 0 0
Columns 8 through 14
0 0 0 0 0 0 0
Columns 15 through 21
0 0 0 0 0 0 0
Columns 22 through 23
0 0
>> zeros( 1, 23 )
ans =
Columns 1 through 7
0 0 0 0 0 0 0
Columns 8 through 14
0 0 0 0 0 0 0
Columns 15 through 21
0 0 0 0 0 0 0
Columns 22 through 23
0 0
% Some other vectors and matrices of constants
>> ones( 1, 23 )
ans =
Columns 1 through 7
1 1 1 1 1 1 1
Columns 8 through 14
1 1 1 1 1 1 1
Columns 15 through 21
1 1 1 1 1 1 1
Columns 22 through 23
1 1
>> eye( 3 )
ans =
1 0 0
0 1 0
0 0 1
>> 49 * ones( 1, 23 )
ans =
Columns 1 through 7
49 49 49 49 49 49 49
Columns 8 through 14
49 49 49 49 49 49 49
Columns 15 through 21
49 49 49 49 49 49 49
Columns 22 through 23
49 49
>> % powers of 10 from 10^1 to 10^5
>> logspace( 1, 5, 5 )
ans =
Columns 1 through 3
10 100 1000
Columns 4 through 5
10000 100000
>> % powers of 2 from 2^1 to 2^16
>> logspace( log10(2), 16*log10(2), 16 )
ans =
1.0e+04 *
Columns 1 through 4
0.0002 0.0004 0.0008 0.0016
Columns 5 through 8
0.0032 0.0064 0.0128 0.0256
Columns 9 through 12
0.0512 0.1024 0.2048 0.4096
Columns 13 through 16
0.8192 1.6384 3.2768 6.5536