Organize Excel date and time data

조회 수: 10 (최근 30일)
Lauren Kilgore
Lauren Kilgore 2019년 11월 22일
댓글: Guillaume 2019년 11월 22일
I am trying to sort this data by date and time. In the file attached, you can see that the time and date are in the same cell. I have tried sort without any luck. I am wondering if it is possible to display a graph for each date and then plotting the times for that date.
  댓글 수: 3
Lauren Kilgore
Lauren Kilgore 2019년 11월 22일
편집: Lauren Kilgore 2019년 11월 22일
I attached an updated excel file. I would like to organize the data by the date/time and the reader. From there, I would like to plot a line graph to show the trend of students visiting the tutoring center by each room.
Guillaume
Guillaume 2019년 11월 22일
I'm unclear on what would go on the X and Y axis of your line graph.

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2019년 11월 22일
It's trivial to sort if you read the data in a table or a timetable:
data = readtable('Practice.xlsx', 'ReadVariableNames', false);
sorteddata = sortrows(data, 1); %sort rows according to first column
or
data = readtimetable('Pracice.xlsx', 'ReadVariableNames', false);
sorteddata = sortrows(data, 'Time') %sort rows according to time
However, for plotting per day you don't even need to sort the function, you can use groupsummary with a grouping by day to call your plotting function with the data of each day. With you demo excel file, it's unclear what you want to plot since the 2nd column is made of names. But it'd go something like this
%demo with timetable
data = readtimetable('Practice.xlsx', 'ReadVariableNames', false);
%for this demo adding a numerical column with random numbers for plotting. Now idea what you want to plot
data.Numbers = rand(height(data), 1)
%plotting
figure; hold('on')
gplot = groupsummary(data, 'Time', 'day', @plot, 'Numbers');
legend(gplot.day_Time);

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by