Hi everybody,
is it possible to use in a for loop over a vector the value of the next step?
e.g. if got a vector like this:
h_x=[0 0 0 -2 -15 -100 -50 50 0 0 0 0]
and a loop using the vector
for test=h_x if test==0 disp('No') else if test-1 ==0 a=test %when the value of the step before was 0, it should just use the value of the current step without any operations into a new Vector 'a'
if test+1 ==0 a=test %when the value of the step after is 0, it should just use the value of the current step without any operations into a new Vector 'a'
end end a=h_x+(10*(test+1))+(10*(test-1)) %Here the current value and 10 times the value of the vector step befor and after should be put into the new vector 'a'
endend
This should result in a vector a like this:
a=[0 0 0 -2 (-15+(10*-2)+(10*-100)) (-100+(10*-15)+(10*-50)) (-50+(10*-100)+(10*50)) 50 0 0 0 0]a=[0 0 0 -2 -1035 -750 -550 50 0 0 0 0]
Does anyone has a hint for me how to include the next steps of the for loop into the formula?
Thank you in advance and very best
Christian
Best Answer