How to compute relative change from starting to ending ?

10 views (last 30 days)
relative change

Accepted Answer

Jan
Jan on 21 Oct 2014
Edited: Jan on 21 Oct 2014
Let me guess:
x = rand(5, 1);
rel_change = diff(x) ./ x(1:length(x) - 1);
[EDITED] Or perhaps:
rel_change = (x - x(1)) ./ x;

More Answers (1)

Star Strider
Star Strider on 20 Oct 2014
rel_change = (x(end)-x(1))/x(1);
  4 Comments
Abinet
Abinet on 21 Oct 2014
Sorry for making confusion, What I mean a record is the values in the column. In short, I am looking for a relative change computation of a single column which contains many values. for example: x= rand(2000,1) How to compute a relative change from staring point till the end?
Thanks!
Jan
Jan on 21 Oct 2014
Edited: Jan on 21 Oct 2014
Again: Please clarify the question by editing the original question. This is the place where readers expect and find all information. Comments disappear soon in the standard display, when further comments are posted.
Please do not use a random input and no output to define the mathematical meaning of your question. What do you expect for:
x = [1,3,-2,10]
? And please add this to the question above, not as an comment. Thanks.

Sign in to comment.

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!