How to convert 30s daily data into hourly data using MATLAB?
Mostrar comentarios más antiguos
I have a daily 30s file.I need to convert it into hourly basis and plot the data on hourly basis. The file consists of 5 coloumns and 2858 rows. First coloumn is the time in second, second column is the second to hour conversion and all other columns are the error measurements(3,4,5).I have to plot each column data(3,4,5) in 24 hour duration with a time scale of 4hrs.I'm using old version of MATLAB.How can I combine these values and plot this.Can anyone please suggest me a solution.
2 comentarios
Dyuman Joshi
el 2 de En. de 2024
"First coloumn is the time in second, second column is the second to hour conversion ..."
How does the conversion work? Just multiply times in seconds with seconds to hour conversion?
What would be the context of the data obtained?
"I have to plot each column data(3,4,5) in 24 hour duration with a time scale of 4hrs"
What do you mean by this?
How is the data obtained related to this?
Aiswarya
el 3 de En. de 2024
Respuesta aceptada
Más respuestas (2)
Dinesh
el 2 de En. de 2024
Hi Aiswarya,
To plot your data on an hourly basis for each error column, you'll need to group the 30 second interval data into hourly averages and then plot each error measurement. The following MATLAB snippet demonstrates how you might average one of the error measurements (3rd column from your data) over each hour. Repeat the process for the other error columns as well.
% Load "data" from your CSV file
timeHours = ceil(data(:, 2)); % Convert to hourly
error1HourlyAvg = accumarray(timeHours, data(:, 3), [], @mean); % Averages for error 1
plot(error1HourlyAvg);
The following link is the documenation for accumarray:
1 comentario
Aiswarya
el 3 de En. de 2024
Alexander
el 2 de En. de 2024
0 votos
Hi Aiswarya,
I also can only assume your intention. My solution would be:
clear
data = dlmread('sample_hourly_shlg_testdata_E.txt',',');
plot(data(:,2), data(:,3:5));grid minor;
xticks([0 4 8 12 16 20 24]); % scale to 4 hours
xlabel('Time [h]');ylabel('your dimension');title('Your Title')
legend('M1','M2','M3');
Hopefully it helps.
3 comentarios
Aiswarya
el 3 de En. de 2024
Alexander
el 4 de En. de 2024
Just for my understanding, what means "not working". Do you get an error message? Or does the code didn't meet you expectations?
Alexander
el 4 de En. de 2024
Are you aware, that you are loosing about 12 min of data between 2623 and 2624?
Categorías
Más información sobre Timetables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







