Create table from an other table
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Peter Perkins
el 15 de Jul. de 2019
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.
Respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!