How to remove elements in a vector using length function?

1 visualización (últimos 30 días)
pavlos
pavlos el 23 de Dic. de 2015
Comentada: Robert Steidl el 23 de Dic. de 2015
Hello,
Consider a vector with length equals 110.
I want to remove the elements that are correspond to the indices that are larger than 100 (a random threshold), i.e. the elements that correspond from 101 to 110 indices.
Thanks.
Pavlos

Respuesta aceptada

Robert Steidl
Robert Steidl el 23 de Dic. de 2015
Hy, hope I can help with your prob:
A=ones(1,110) % Vector with 110 values
threshold=100; A(threshold:end)=[];
Vector A has then the size 1x99
Hope that is what you are looking for
  2 comentarios
pavlos
pavlos el 23 de Dic. de 2015
How it is done with logical comparisons?
For example, A(length(A)>100)=[];
Robert Steidl
Robert Steidl el 23 de Dic. de 2015
Hy,
in my mind the use of length make no sense in this case!!! Could you please explain me why you want to use "Length" for your problem? Have you tried my advice? Tell me why it doesn't fulfil your problem?
greets, Robert

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by