v = [0 8 1 2 6 4 8]
How do I determine length of the vector?
Also, how do I pre-allocate the descending vector with all zeros?
Thank you!

 Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Feb. de 2020

0 votos

length(v)
zeros(size(v))

3 comentarios

Seoyoung Cho
Seoyoung Cho el 10 de Feb. de 2020
thanks a lot!
Seoyoung Cho
Seoyoung Cho el 10 de Feb. de 2020
do you know how to do pre-allocate the ascending vector with all zeros?
Walter Roberson
Walter Roberson el 10 de Feb. de 2020
zeros(size(v)) works no matter whether you are planning to put ascending or descending variables; it also works even if you are planning to put complex numbers in (I mention those because complex numbers cannot generally be ordered into ascending or descending.)

Iniciar sesión para comentar.

Más respuestas (1)

fred  ssemwogerere
fred ssemwogerere el 10 de Feb. de 2020

0 votos

leng=length(v); % length of a vector
pA=zeros(1,leng); % pre-allocation with zeros

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 10 de Feb. de 2020

Comentada:

el 10 de Feb. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by