How do I create another column in a table which basically divides a T+1 / T number?

1 view (last 30 days)
I have a table (let's say X) with various colums. The first column is based on date.
I thought I could just do this;
DataVTAQ.Ret = (DataVTAQ(1,6)./(DataVTAQ(2,6)))
So I create a new column (RET), which is nothing else but the % change between 2,6 and 1,6 (a lag of t-1) basically.
How would one go about that?

Answers (1)

KSSV
KSSV on 5 Apr 2021
x = rand(10,1) ;
y = rand(10,1) ;
T = table(x,y)
T = 10×2 table
x y _______ ________ 0.13482 0.74789 0.40312 0.25586 0.31269 0.604 0.83958 0.52914 0.31587 0.46031 0.79854 0.25194 0.81289 0.082865 0.17218 0.69191 0.54784 0.15748 0.21236 0.57421
T.ratio = T.y./T.x
T = 10×3 table
x y ratio _______ ________ _______ 0.13482 0.74789 5.5472 0.40312 0.25586 0.63469 0.31269 0.604 1.9317 0.83958 0.52914 0.63024 0.31587 0.46031 1.4573 0.79854 0.25194 0.3155 0.81289 0.082865 0.10194 0.17218 0.69191 4.0186 0.54784 0.15748 0.28746 0.21236 0.57421 2.7039
  3 Comments
Andy Simmons
Andy Simmons on 5 Apr 2021
What I meant was, rather than where ratio shows (3,2) = 0.63469
Id' my trying to get the figure; 0.342109, which is (Y2)./(Y1), so not
T.ratio = T.y./T.x
but T.ratio = T.y(2)./(T.y(1)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!