필터 지우기
필터 지우기

How to calculate the hourly average

조회 수: 5 (최근 30일)
Pul
Pul 2021년 1월 26일
편집: Pul 2021년 1월 27일
Hi, I should calculate an hourly average of this file.
This is the start of my script:
clear all
Func=importdata('Matlab.csv');
data_num=Funcdata;
data_str=Func.textdata;
data_str_splitted=split(data_str);
for i=1:length(data_str_splitted)
days_code(i,:)=str2double(erase(data_str_splitted(i,1),"/"));
end
Could anyone give me an advice?
Thank you.
  댓글 수: 2
Rik
Rik 2021년 1월 26일
Why don't you first start looking for a way to import your data that makes use of Matlab data types? Have you looked for a function that will read csv files?
It is good to try to write things yourself, but especially when you start using Matlab you should try to see what tools Matlab provides you with.
Rik
Rik 2021년 1월 26일
Why did you flag your question as a duplicate?

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

채택된 답변

Star Strider
Star Strider 2021년 1월 26일
If you have R2016b or later, this is straightforward:
T1 = readtable('Matlab.csv');
First_5_Rows = T1(1:5,:);
TT1 = table2timetable(T1);
TT1 = retime(TT1, 'hourly','mean');
First_10_Rows = TT1(1:10,:)
producing:
First_10_Rows =
10×3 timetable
Var1 Var2 Var3 Var4
___________________ _______ ______ ______
06/23/2015 01:00:00 -30.195 71.304 159.62
06/23/2015 02:00:00 -30.239 71.288 159.57
06/23/2015 03:00:00 -29.93 71.46 158.83
06/23/2015 04:00:00 -29.922 71.487 157.72
06/23/2015 05:00:00 -29.35 71.939 155.11
06/23/2015 06:00:00 -28.742 72.334 156.36
06/23/2015 07:00:00 -28.336 72.619 158.46
06/23/2015 08:00:00 -28.339 72.436 158.91
06/23/2015 09:00:00 -27.784 72.907 157.82
06/23/2015 10:00:00 -27.128 73.226 153.73
.
  댓글 수: 2
Pul
Pul 2021년 1월 26일
Thank you very much!
Star Strider
Star Strider 2021년 1월 26일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by