how do I dynamically change variable name for dataset array?

9 Ansichten (letzte 30 Tage)
Thomas Vargas
Thomas Vargas am 6 Nov. 2012
Bearbeitet: Stephen23 am 19 Jun. 2019
I want to change the names of the dataset arrays. For instance, I want hour1, hour2, hour3, day1, day2, day3, fivemin1, fivemin2, and fivemin3. Unfortunately, I am getting variables with those names, but not in the way that I want. All the values are getting placed into variablea hour, day, and fivemin.
hour = dataset
day = dataset
fivemin = dataset
for i = 1:3
eval(sprintf('hour%d = [1:i]', i))
eval(sprintf('day%d = [1:i]', i))
eval(sprintf('fivemin%d = [1:i]', i))
fileName = ['GPL_OCT_' num2str(i) '_hour.xls']
hour = [hour; dataset('xlsfile', fileName)]
fileName = ['GPL_OCT_' num2str(i) '_hour.xls']
day = [day; dataset('xlsfile', fileName)]
fileName = ['GPL_OCT_' num2str(i) '_5min.xls']
fivemin = [fivemin; dataset('xlsfile', fileName)]
end

Antworten (2)

Daniel Shub
Daniel Shub am 6 Nov. 2012

Stephen23
Stephen23 am 12 Jan. 2016
Bearbeitet: Stephen23 am 19 Jun. 2019

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by