storing tables in an array and calling them whithin a for loop
Show older comments
I am a novice in MatLab. I have 30 different tables that imported in Matlab as CSV files. I want to choose two pairs of the tables and read a column Return of them and store it in ret_1 and ret_2 variables. Something like the following code:
data = {'AAPL', 'AXP', 'BBN'};
for i = length(data)
for j = length(data)
ret_1 = data(i).Return;
ret_2 = data(j).Return;
end
end
But I get an error, as data(i) doesn't include the content that I want to. I tried
eval(data(i)) but it says that eval() works only with strings and not arrays.
My data looks like the following in CSV files that I imported them into MatLab.
'AAPL' =
Date Low Close Return
6/3/1997 16.750 16.935 16.687
6/4/1997 16.625 16.756 16.625
6/5/1997 16.625 17.125 16.687
'AXP' =
Date Low Close Return
6/3/1997 69.079 70.075 68.750
6/4/1997 69.079 69.079 68.500
6/5/1997 68.078 69.876 67.750
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!