trimming the first and last elements of a vector

17 次查看(过去 30 天)
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

采纳的回答

dpb
dpb 2016-8-19
Reassign in place...
yhat=yhat(h+1:end-h);
  5 个评论
dpb
dpb 2016-8-20
编辑:dpb 2016-8-20
Could be the last 9 were zero before truncating three of them...

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by