Vectorizing a recursive for-loop
이전 댓글 표시
Hey, I need help vectorizing this for-loop. In general, I need help vectorizing a for-loop with a term that references it's previous value.
In my case, DT is already a vector, and I want to fill out the Time vector as such
Time = zeros(1,N)
Time(1) = DT(1)/2
for i=2:N
Time(i)=Time(i-1)+0.5*(DT(i)+DT(i-1));
end
Is there a simple vectorization to this for loop?
Thank you.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!