Assign values to numbers and recount after a fixed interval
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi.I have to assign number values to each day's each hour's precipitaton values. (starting from 1,end at 730 as the data is for two years). I want that the when the next day's 12:00am strikes it restarts counting from 2. e.g. And then when next year's date and time occur, it again gets a value of 1. Basically the values should be independent of the year.
Date Time Precipitation Values
1-1-1987 00:00 19 1
1-1-1987 01:00 19.2 1
.
.
1-1-1987 23:00 20 1
2-1-1987 00:00 25 2
.
.
12-31-1987 22:00 0.2 365
12-31-1987 23:00 0.4 365
.
.
1-1-1988 00:00 1.2 1
1-1-1988 01:00 3.4 1
Can anyone guide how to do this using loops?
답변 (2개)
Murugan C
2020년 2월 18일
consider excel as my input.
[numdata, textdata, rawdata] = xlsread('Test_data.xlsx');
timecolomn = (datestr( numdata(:,1), 'HH:MM' ));
for i = 1 : length(timecolomn)
g = strsplit(timecolomn(i,:),':');
if str2double(g{2}) == 0
value1{i} = str2double(g{1});
end
end
value_row = ['Values'; value1'];
rawdata = [rawdata value_row];
xlswrite('AddedValue.xlsx', rawdata)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!