box plot from timetable data

16 Ansichten (letzte 30 Tage)
GIULIA
GIULIA am 29 Sep. 2025 um 8:41
Kommentiert: Mathieu NOE am 13 Okt. 2025 um 11:32
Hello all,
I have a set of precipitation data 7440x4 double, where 1st column is year, 2nd is month, 3rd is day, and last 4th column is precipitation values (mm/day).
I had to find the monthly maxima and applied the code below. Although I also need to create a boxplot displaying the monthly maxima across the years, with time labelled on the x axis.
Could you please provide some help in creating a boxplot from timetable data? Should I convert it into a matrix? How do I do it?
Thanks a lot for your help
mm=precip(:,4);
Times = datetime(precip(:,1:3)); %convert to datetime
table = timetable(Times, mm); % Convert To ‘timetable’
monthly_max = retime(table, 'monthly', 'max');

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 29 Sep. 2025 um 9:56
hello Giulia
you can do a box plot directly with timetable data
example :
% Create a sample timetable
time = datetime({'2025-01-01'; '2025-01-02'; '2025-01-03'; '2025-01-04'; '2025-01-05';'2025-02-01'; '2025-02-02'; '2025-02-03'; '2025-02-04'; '2025-02-05'});
data = [10; 15; 20; 25; 30 ; 40; 45; 50; 55; 60];
TT = timetable(time, data);
% Extract data for the box plot
values = TT.data;
% Create the box plot
boxplot(values);
% Add labels and title
title('Box Plot of Timetable Data');
ylabel('Values');
% Group data by month (example)
TT.Month = month(TT.time); % Add a grouping variable
boxplot(TT.data, TT.Month);
% Add labels and title
title('Box Plot Grouped by Month');
xlabel('Month');
ylabel('Values');
  2 Kommentare
GIULIA
GIULIA am 13 Okt. 2025 um 11:03
Thanks a lot for your help Mathieu!
Mathieu NOE
Mathieu NOE am 13 Okt. 2025 um 11:32
as always , my pleasure !

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Weather and Atmospheric Science 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