MATLAB: Inflow: weekly to hourly, linear interpolation

inflowinterplinterpolationlinearMATLABsplinewater

Hey everybody! I bit confusing, I believe I have a fundamental wrong understanding of my math.
How do I calculate hourly water inflow from weekly inflow?
background: I am working on an optimisation problem and all my data (price, wind, solar) is in hourly timesteps, just my inflow is weekly. I got weekly inflow data (see code), e.g., in week 2 –> 232 million m3 water flow into a certain reservoir.
If I were to calculate a step-interpolation (every hour the same amount of water), it would be 1.38 million m3 / per hour (168*1.38 = 323). Whats about linear interpolation? I tried the build-in interpl function, but received the y-axis point of the graph, not the actual inflow. E.g., in [hour = inflow] hour 167 = 231.9464, hour 168 = 232, hour 169 = 232.0535 – which is wrong because the oveerall weekly inflow would be much greater than 323. I tried to subtract the weekly inflow (e.g., 232) from the calculated value, but even then I get the wrong overall inflow (e.g., 750 milliom m3). Remeber, the overall inflow in week two should be 323 million m3. I searched answers and found a bit on temperature or index values, where interpolation in the way I did below makes sense. But, with the extra constraint that the sum of hourly inflows needs to be the weekly inflow, I cannot get my head around.
How do I calculate a linear or even a spline interpolated inflow of each hour?
clear all var
%hourly inflow
inflow_weekly = [223 232 241 437 308 246 192 77 62 59 63 53 86 129 328 1626 1439 1189 3849 2463 1798 1956 1181 1376 902 445 308 209 188 241 690 1118 1430 854 626 1321 2858 2426 1881 1123 1918 888 1132 503 957 1259 245 465 433 153 203 362];
%time set
t = 1:168:52*168 ;
% interpolation
ti = 1:1:52*168 ;
inflow_hourly = interp1(t,inflow_weekly,ti) ;
%graph
plot(t,inflow_weekly,'.-r')
hold on
plot(ti,inflow_hourly,'b')
legend('Original', 'interpolated')
Here is the inflow as well as the interpolated inflow.

Best Answer

The calculation/thoughts of darova did the trick! Thanks again!
t = 0:168:51*168;
ti = 0:1:51*168;
a1 = sum(inflow_weekly);
a2 = sum(inflow_hourly)/168;
a1-a2 % summary for year: close to zero
Sadly, still no idea why the difference between interpolated inflow and non-interpolated inflow.