The linspace function produces an array or matrix filled with a requested number of numbers starting at a given value and ending at a given value. There will be exactly the requested number of values, evenly spaced between the start and end.
The linspace function allows you, the programmer, to create an instantiated array. You must say what the first number in the array is. You must say what the last number in the array is. You must say how many numbers the array is to hold. Linspace will then create a list of evenly spaced numbers fulfilling your requirements.
% create an array from 1 to 10 with 5 values
values = linspace(1, 10, 5)
ans =
1.0000 3.2500 5.5000 7.7500 10.0000
% create a matrix starting at 0 going to 20 with 100 values
values = linspace(0,20,100)
values =
Columns 1 through 7
0 0.2020 0.4040 0.6061 0.8081 1.0101 1.2121
Columns 8 through 14
1.4141 1.6162 1.8182 2.0202 2.2222 2.4242 2.6263
Columns 15 through 21
2.8283 3.0303 3.2323 3.4343 3.6364 3.8384 4.0404
Columns 22 through 28
4.2424 4.4444 4.6465 4.8485 5.0505 5.2525 5.4545
Columns 29 through 35
5.6566 5.8586 6.0606 6.2626 6.4646 6.6667 6.8687
Columns 36 through 42
7.0707 7.2727 7.4747 7.6768 7.8788 8.0808 8.2828
Columns 43 through 49
8.4848 8.6869 8.8889 9.0909 9.2929 9.4949 9.6970
Columns 50 through 56
9.8990 10.1010 10.3030 10.5051 10.7071 10.9091 11.1111
Columns 57 through 63
11.3131 11.5152 11.7172 11.9192 12.1212 12.3232 12.5253
Columns 64 through 70
12.7273 12.9293 13.1313 13.3333 13.5354 13.7374 13.9394
Columns 71 through 77
14.1414 14.3434 14.5455 14.7475 14.9495 15.1515 15.3535
Columns 78 through 84
15.5556 15.7576 15.9596 16.1616 16.3636 16.5657 16.7677
Columns 85 through 91
16.9697 17.1717 17.3737 17.5758 17.7778 17.9798 18.1818
Columns 92 through 98
18.3838 18.5859 18.7879 18.9899 19.1919 19.3939 19.5960
Columns 99 through 100
19.7980 20.0000