Difference between two iteration of for loop

Hi I need to have difference between to successive iteration of for loop. As example:
For i=1:n P(i)=statement; end
How can I calculate: DeltaP=P(i)-P(i-1)??!! THANKS

 Accepted Answer

diff( P )
after the for loop should do this for you for all pairs of consecutive elements of P

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Asked:

on 12 Jun 2018

Commented:

on 12 Jun 2018

Community Treasure Hunt

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

Start Hunting!