Dear Community, I'm now on ThingSpeak for nearly 4 weeks and I'm struggling to compute some MATLAB data. Mostly because I don't know the syntax. I have a hourly graph of solar production in kW, I'm taking a sample every 20 seconds, and I would like to aggregate the data on a daily basis in kWh. I guess I need to select the last 7 days of data using some thingsread function, add the data into an array and compute the daily data into an average/sum ... As you can see, I mostly got the mechanics but I'm struggling to create the car ;) Is there anyone kind enough to assist me ? Thansk a lot ! How to compute and aggregate energy production Here it is in two glorious lines. Ive done it using the traffic monitor channel, since it posts data every 15 seconds, you can't read 7 days in one try. myData=thingSpeakRead(38629,'numdays',2,'outputformat','timetable'); newData=retime(myData,'hourly','sum'); Wow .... Ok let me try on my side and I'll let you know what I came up with ! Ok, so I gave it a try but without luck : Here is the code section : %% Read Data %% [data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumDays', 2, 'ReadKey', readAPIKey); newData=retime(data,'hourly','sum'); %% Visualize Data %% plot(time, newData); title("Last 2 days Aggregation"); xlabel("Time"); ylabel("Production (Wh)"); I'm having this error : Incorrect number or types of inputs or outputs for function 'retime'. Error in aggregate (line 21) newData=retime(data,'hourly','sum'); In case of you wonder, Line 21 is where retime is used. Look at what else is different about the code I gave you, especially in the first line. I understood, I'm using an array with 2 dimensions ? right ? I'm sorry I'm discovering this language... Sure, welcome to MATLAB. Also look the the name, value pairs I used at the end to get a timetable output. The retime function needs a timetable to act on. You can see those requirements in the doc. MATLAB has famously good doc. I'm sorry but I'm still not able to do anything :-/ Please show me what you tried and what result you are getting. Here is some updated code. myData=thingSpeakRead(readChannelID,'numdays',2,'outputformat','timetable'... ,'ReadKey', readAPIKey); newData=retime(myData,'hourly','sum'); %% Visualize Data %% plot(newData.Timestamps, newData.(1)); title("Hourly Aggregation"); xlabel("Time"); ylabel("Production (Wh)"); Hi Christopher, Thanks a lot. I know what's hapening ... Matlab is too powerful ;) So, I have the data plot now, how can I geet a full week ? I can seemax 3 days. I know you're stating above I cannot see 7 days in one try, can you elaborate on that ? Since we are aggregating data now, we should have less data in one go ? Can you try the MATLAB onramp? Its really helpful to get going. If you still have troubles after that, consider starting a new thread on MATLAB answers. matlab aggregating data solar production formula help