How to get from a array to a vector

1 visualización (últimos 30 días)
Mark Loui
Mark Loui el 18 de Mzo. de 2021
Respondida: Jan el 19 de Mzo. de 2021
Hi there i have a question
n=10;
x=rand(n,1)
for i=1:n-1
h(i)=x(i+1)-x(i);
iter_h=iter_h+1;
end
I get the ouput which is in array is this right? If so how can i change to a vector?

Respuesta aceptada

Jan
Jan el 19 de Mzo. de 2021
Vectors are arrays.
Your code does not use iter_h anywhere. It can be simplified to:
n = 10;
x = rand(n, 1);
h = diff(x);

Más respuestas (0)

Categorías

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

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by