Skip to contents

Construct a vector of n linearly-spaced elements from a to b.

Usage

linspace(a, b, n = 50)

Arguments

a

The starting value of the sequence.

b

The final value of the sequence.

n

The number of samples to generate. Default is 50.

Value

A vector of linearly-spaced elements.

See also

Examples

linspace(0, 1)
#>  [1] 0.00000000 0.02040816 0.04081633 0.06122449 0.08163265 0.10204082
#>  [7] 0.12244898 0.14285714 0.16326531 0.18367347 0.20408163 0.22448980
#> [13] 0.24489796 0.26530612 0.28571429 0.30612245 0.32653061 0.34693878
#> [19] 0.36734694 0.38775510 0.40816327 0.42857143 0.44897959 0.46938776
#> [25] 0.48979592 0.51020408 0.53061224 0.55102041 0.57142857 0.59183673
#> [31] 0.61224490 0.63265306 0.65306122 0.67346939 0.69387755 0.71428571
#> [37] 0.73469388 0.75510204 0.77551020 0.79591837 0.81632653 0.83673469
#> [43] 0.85714286 0.87755102 0.89795918 0.91836735 0.93877551 0.95918367
#> [49] 0.97959184 1.00000000
linspace(1, 5, 5)
#> [1] 1 2 3 4 5
linspace(1 + 2i, 10 + 10i, 8)
#> [1]  1.000000+ 2.000000i  2.285714+ 3.142857i  3.571429+ 4.285714i
#> [4]  4.857143+ 5.428571i  6.142857+ 6.571429i  7.428571+ 7.714286i
#> [7]  8.714286+ 8.857143i 10.000000+10.000000i
logspace(0, pi, 10)
#>  [1] 1.000000 1.135635 1.289667 1.464592 1.663242 1.888837 2.145029 2.435971
#>  [9] 2.766375 3.141593