Q:

What is the function of the linspace in MATLAB?

A:

The "linspace" function in MATLAB creates a vector of values that are linearly spaced between two endpoints. The function requires two inputs for the endpoints of the output vector, and it also accepts a third, optional input to specify the number of points to include between the endpoints. If this third input is omitted, the resultant vector includes 100 values.

Keep Learning

The "linspace" function operates similarly to the ":" operator, which allows a user to create a vector between two endpoints with a stepsize of 1. However, the "linspace" function includes greater flexibility, as the number of steps can be specified, allowing intervals of values other than 1.

The syntax for the "linspace" function follows the form "x = linspace (3,11,5);" -- this line of code produces an output vector saved in the variable x comprised of a list of 5 numbers evenly spaced between 3 and 11 -- and the resultant vector is [3, 5, 7, 9, 11]. The semicolon at the end of the line of code suppresses output to the MATLAB command window. Without this semicolon, the resultant vector displays on the screen as the program runs. Even if suppressed, the vector is saved in the variable x.

The inputs to the "linspace" function can be input as number values, as in the example above, and need not be integers. Alternatively, variables can be used as the input values.

Sources:

Related Questions

• A: MATLAB is a high level programming language used in numerical computing. It is widely used in academia, engineering and science. MATLAB is used for signal ... Full Answer >
Filed Under:
• A: The natural logarithm function in MATLAB is log(). To calculate the natural logarithm of a scalar, vector or array, A, enter log(A). Log(A) calculates the ... Full Answer >
Filed Under:
• A: A MATLAB 3-D plot is a three dimensional graphical display of either a function or data points produced by MATLAB. MATLAB is both a programming language an... Full Answer >
Filed Under:
• A: The expression pi in MATLAB returns the floating point number closest in value to the fundamental constant pi, which is defined as the ratio of the circumf... Full Answer >
Filed Under:
PEOPLE SEARCH FOR