Very simple question but I am an absolute beginner, so apologies if this has already been answered.
I need to pick sequential elements of a list, excluding t=1 and t=T, and use them in a function. For ht the list element in position t,
h:={h1,h2,h3,...hT}
hnew=f[t_]:=h[[t-1]]-h[[t+1]]
Then I want to update the existing value of $h_t$ by $h_{new}$, where $h_{new} = h_{t-1}-h_{t+1}$ and repeat until T-1 (second to last element).
Please note that I heed the definition h:={}
because at the end of the process the updated vector will replace the original one (this is part of a bigger loop).
I have tried ReplacePart
and a Do
loop but I could not get them to work.
Again, I apologise for the format and if this question has already been asked.
{}
button in the editor for proper formating. $\endgroup$