Sort Matlab table, monthly and seasonally. plot mean and trend seasonal map

13 visualizaciones (últimos 30 días)
I am processing ocean and climate data (1982-2022). Here, I have table which having heatwaves events details. Now, I want to sort the data month wise and also seasonal wise (summer:October- February, and winter:March-September), and then i wanted to plot mean seasonal and trend.
Sample file is attached. length of original file may vary in size.
Thanks in addvance.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 23 de Mayo de 2023
Use sortrows to sort your table.
Create a column of month names using month. Convert them to categorical values and use mergecats to combine these into 2 categories - Summer and Winter.
Share what you have tried so we can help more.
  4 comentarios
Gurumoorthi K
Gurumoorthi K el 26 de Mayo de 2023
Your code works well. But need some changes for my case. My data MHW is not in regular date, its a heatwaves event (e.g. 2-4 events per year). So ''D'' may not be required. Now, we must use "T or table_in" while using the conditional statement "S". Can you please give me some details?
Note: The dimension of table_in is 197080x9 table.
table_in=MHW;
D = (datetime(1982,1,1):datetime(2020,12,31))';
T = table({table_in});
S = month(T.D)<3 | month(T.D)>9;
W = ~S;
Summer = T(S,:)
Winter = T(W,:)
Cris LaPierre
Cris LaPierre el 26 de Mayo de 2023
Editada: Cris LaPierre el 26 de Mayo de 2023
I created a simple example to show you how to use the functions I mentioned in my original post. You already have the date info in your data, so you don't need to create D. However, you do need to convert your data into datetime variables. Try this:
load table_1.mat
MHW3.mhw_onset = datetime(MHW3.mhw_onset,"ConvertFrom","yyyymmdd");
MHW3.mhw_end = datetime(MHW3.mhw_end,"ConvertFrom","yyyymmdd")
MHW3 = 24×9 table
mhw_onset mhw_end mhw_dur int_max int_mean int_var int_cum xloc yloc ___________ ___________ _______ ________ ________ __________ _______ ____ ____ 01-Jan-1982 07-Jan-1982 7 1.0344 0.73135 0.20371 5.1194 1 11 30-Jan-1982 05-Feb-1982 7 1.3971 1.1062 0.18736 7.7435 1 11 12-Jul-1982 25-Jul-1982 14 0.068631 0.05372 0.01268 0.75207 1 11 29-Jul-1982 11-Aug-1982 14 0.062454 0.046373 0.010259 0.64922 1 11 05-Sep-1982 21-Oct-1982 47 0.069312 0.047799 0.0096679 2.2466 1 11 31-Jan-1983 06-Feb-1983 7 1.1801 0.8704 0.16281 6.0928 1 11 25-Feb-1983 06-Mar-1983 10 0.63149 0.53797 0.0501 5.3797 1 11 24-Jun-1983 28-Jun-1983 5 0.04795 0.045557 0.0047146 0.22778 1 11 28-Jul-1983 02-Aug-1983 6 0.045389 0.041644 0.005188 0.24986 1 11 25-Aug-1983 01-Sep-1983 8 0.05064 0.043116 0.0070944 0.34493 1 11 18-Sep-1983 26-Sep-1983 9 0.0478 0.04056 0.0040666 0.36504 1 11 27-Apr-1984 10-May-1984 14 0.13791 0.10205 0.022857 1.4286 1 11 23-May-1984 07-Jun-1984 16 0.093507 0.067273 0.012935 1.0764 1 11 28-Jun-1984 07-Jul-1984 10 0.058696 0.046507 0.0080467 0.46507 1 11 27-Jul-1984 02-Aug-1984 7 0.035929 0.035113 0.00058924 0.24579 1 11 09-Oct-1984 17-Oct-1984 9 0.069806 0.055207 0.01051 0.49687 1 11

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by