Skip to Main Content Skip to Search
Product Documentation

linspace - Generate linearly spaced vectors

Syntax

y = linspace(a,b)
y = linspace(a,b,n)

Description

The linspace function generates linearly spaced vectors. It is similar to the colon operator ":", but gives direct control over the number of points.

y = linspace(a,b) generates a row vector y of 100 points linearly spaced between and including a and b.

y = linspace(a,b,n) generates a row vector y of n points linearly spaced between and including a and b. For n < 2, linspace returns b.

Examples

Create a vector of 100 linearly spaced numbers from 1 to 500:

A = linspace(1,500);

Create a vector of 12 linearly spaced numbers from 1 to 36:

A = linspace(1,36,12);

See Also

colon operator | logspace

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS