Borrar filtros
Borrar filtros

trimming the first and last elements of a vector

14 visualizaciones (últimos 30 días)
Osita Onyejekwe
Osita Onyejekwe el 19 de Ag. de 2016
Editada: dpb el 20 de Ag. de 2016
let's say that i have a vector of yhat =506x1 and i have an h = 3 value
how do I remove the first 3 elements and the last 3 elements of yhat so that it will be a 500x1 vector.
I currently wrote, yhat(h+1:end-h); but it gives me 6 zeros for the last results, and that is not what i want.
How do i fix this? I just want a new vector of yhat where it is 500x1 because I removed the first 3 and last 3 elements based on the size of h. thank you!
Thank you verym uch

Respuesta aceptada

dpb
dpb el 19 de Ag. de 2016
Reassign in place...
yhat=yhat(h+1:end-h);
  5 comentarios
Osita Onyejekwe
Osita Onyejekwe el 20 de Ag. de 2016
thanks guys!!!
dpb
dpb el 20 de Ag. de 2016
Editada: dpb el 20 de Ag. de 2016
Could be the last 9 were zero before truncating three of them...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements 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