How to sequentially process the columns of a table?
Show older comments
Dear Experts,
I have a table, tableA as shown below.
tableA
portfolio0 portfolio1 portfolio2 ... portfolio9 returns date
XX XX XX XX XX 199901
XX XX XX XX XX 199901
XX XX XX XX XX 199901
....
XX XX XX XX XX 199901
I can compute the total return for column 1 as
portfolio0 = tableB.portfolio0 .* tableB.returns.
However, when i do the following, I have an error. When I use
tableB.strcat('portfolio', 'i') = tableA.strcat('portfolio', 'i') .* tableA.returns where i = 0 to 9.
How do I process portfolio0 to portfolio9 together and store it like tableB as shown below.
tableB
portfolio0 portfolio1 ... portfolio2 date
XXX XXX XXX 199901.
In actual case, I will have tableA for different date and the processing are shown above. Hence the final tableB will look like
tableB
portfolio0 portfolio1 ... portfolio2 date
XXX XXX XXX 199901
XXX XXX XXX 199902
....
XXX XXX XXX 199912
Thank you so much for your advice LL
Answers (1)
Walter Roberson
on 8 Mar 2017
0 votes
https://www.mathworks.com/help/matlab/ref/varfun.html
1 Comment
Cheerful
on 10 Mar 2017
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!