Gary
Gary

Reputation: 2167

Confused about how to reshape my data, column for each day

I am pulling in a file which contains two columns. My first column is a timestamp column, with the date/time being indexed every minute over the course of 30 days. My second column is my data column, where each row corresponds to the value logged at that minute from the Time Stamp.

My goal is to reshape my data so that each day is in it's own column, as shown by the diagram below. The "Current" is what my data currently looks like. The "Goal" is what I would like my dataset to look like, and I am having trouble figuring out how to get there.

Any help is appreciated!

enter image description here

Upvotes: 0

Views: 53

Answers (1)

Florian
Florian

Reputation: 1824

You write "every minute over the course of 30 days", which means you have essentially 60*24*30 rows. In this case, what you need to do is simply reshape(data(:,2),[60*24,30]). This gives an array with 60*24 rows (each row corresponding to one minute of the day) and 30 columns (each column corresponding to one day).

Upvotes: 1

Related Questions