What is the difference between a vector and using linspace?

8 visualizaciones (últimos 30 días)
Kristen Hunn
Kristen Hunn el 31 de Ag. de 2015
Respondida: Star Strider el 31 de Ag. de 2015
I know that sometimes the formula var_name = linspace (xi,xf,n) is used and sometimes var_name = [m:q:n] when do you differentiate between using either?

Respuestas (1)

Star Strider
Star Strider el 31 de Ag. de 2015
The linspace function produces a vector of fixed length (defined by the third argument) between the limits defined by the first two. The function determines the step size.
The colon operator defines a vector from the start, step, and end values, and as the result the length is determined by those values.
I generally use linspace when I want to determine the length, and usually use the colon operator when I want integer values in the vector. Personal preference, others likely have different views.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by