필터 지우기
필터 지우기

Inserting zeros between two rows in an array

조회 수: 1 (최근 30일)
Swasti Khuntia
Swasti Khuntia 2012년 6월 26일
I've an array of date and time {1 month} in 1 column and some data in another column. The data is for 30 days but it's from time 08:00:00 till 21:59:00. I want to insert zeros in the time frame 22:00:00 to 07:59:00.
Any ideas/solutions are highly obliged. Thanks !!!!!
More INFO: For e.g., in January, there are (31x24x60=44640) minutes. But I don't have data for every minute. So, I want to enter a '0' for the unavailable data. So, that in the end I have 44640x2 array.

채택된 답변

Walter Roberson
Walter Roberson 2012년 6월 26일
You can create the list of times using addtodate
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 6월 26일
Separate your two columns into two arrays. reshape() each so that the number of rows is the same as the number of entries per day that you actually have. vertcat() on the addate() results to the date array. vertcat() a zero() of the appropriate size to the data array. reshape each of them back to one column. horzcat() the two columns together.
Swasti Khuntia
Swasti Khuntia 2012년 6월 26일
Hello Walter, I'm extracting my data from an Excel file. Hence, the char and num rows are stored separately in two arrays. How can I insert date & time and '0' in between 2 time-frames? Like, for the first day, the data ends at 21:59:00 and it starts the next day at 08:00:00. So, I want to insert the time date/time like
22:01:00 0
22:00:00 0
.
.
.
.
07:59:00 0
And, then again the data starts.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by