Borrar filtros
Borrar filtros

What is the difference between linspace and the colon operator in this code?

2 visualizaciones (últimos 30 días)
Hi! What is the difference between the linspace function and the colon operator in this code?
v1 = (0:1/200:1);
v2 = linspace(0,1,200);
>> v1==v2
Matrix dimensions must agree.
Why is there one element more in v1 than in v2?
Thank you very much Timo

Respuesta aceptada

Matt J
Matt J el 12 de Nov. de 2017
Editada: Matt J el 12 de Nov. de 2017
Because the interval between the elements of v2 is not 1/200. It's 1/199.
>> isequal(v2(2)-v2(1),1/199)
ans =
logical
1
That is the separation needed to get 200 equally spaced points.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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