Create table from an other table

3 次查看(过去 30 天)
Hello everyone,
I created 33 tables containing 3 row with date (from 2002 to 2018 with day and month) and longitude, lattitude with the following code :
T = readtable('SouthernAfrica_0810.csv');
T.acq_date = datetime(T.acq_date,'F','dd/MM/uuuu');
SouthernAfrica_0810 = [T(:,6), T(:,1:2)];
save SouthernAfrica_0810.mat SouthernAfrica_0810
I would like to create tables representing the same thing for each month of each years wich make around 3000 tables (I need it to plot maps of fire pixels) but I'm not really feeling like doing it one by one...
Does anyone have an idea how to automatize the creation of those monthly tables for one the main table (I have linked one of the table in this message) ?
Thanks you, have a good day,
Thomas V.
  8 个评论
Peter Perkins
Peter Perkins 2019-7-15
If you are just making one plot, the simplest thing is to just create a smaller table. This code assumes a fiarly recent version of MATLAB, but you can do more or less the same thing using earlier versions:
>> tt = timetable(rand(100,1),rand(100,1), ...
'StartTime','1-Jan-2002','TimeStep',caldays(1), ...
'VariableNames',["X" "Y"]);
>> ttJan2002 = tt(timerange('Jan-2002','months'),:)
ttJan2002 =
31×2 timetable
Time X Y
___________ ________ _________
01-Jan-2002 0.81472 0.16218
02-Jan-2002 0.90579 0.79428
03-Jan-2002 0.12699 0.31122
04-Jan-2002 0.91338 0.52853
05-Jan-2002 0.63236 0.16565
>> plot(ttJan2002.X,ttJan2002.Y);
I realize that sounds counter to what people have been saying, but for one plot, it's fine.
If you want to make thousands of such plots, then I would think you'd want to put that code into a loop, or use rowfun to make the plots. To use rowfun, you will probably want to add a couple of grouping variables to your timetable for monh and year number, using the month and year functions on your datetime.
Thomas Vescovini
Thomas Vescovini 2019-7-16
Ok thank you, I think I will try it but you are right, I'm just going to lose my time with it...
I'm closing the subject!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by