Calculate the total average daily load

3 views (last 30 days)
Abm
Abm on 11 Jun 2019
Commented: Abm on 12 Jun 2019
Hi guys,
I want to calculate the total average daily load consumption for a microgrid. I have the hourly load data and I tried by doing like this:
%% designing the minigrid according to IEEE standard:
% convert the load data from watthours to Amperehours:
%mean_load_Wh=mean(Dataclean_interpolated.InverterEnergy)
Power_Ah=Dataclean_interpolated.InverterEnergy./Dataclean_interpolated.BatteryVoltage;
% calculate the total average daily load:
mean_load=retime(Power_Ah,'daily','mean');
K_p=0.1;% Parasitic losses
D=6; % 10.5 or 6 or 3 ( days of autonomy) depending on different IEEE standards)
C_un=D.*(mean_load.*(1+K_p))
%the adjusted battery capacity:
%C_ad=(C_un X K_t X K_m)/DOD
K_t=1.048; % temp.correction factor
K_m= 1.25;% Design margin
DOD=0.50;% maximum daily depth of discharge
C_ad=(C_un * K_t * K_m)/(DOD)% final battery capacity in Ah
but I get this message:
Undefined function 'retime' for input arguments of type 'double'.
Error in test_func (line 98)
mean_load=retime(Power_Ah,'daily','mean');
I have very basic knowlage in matlab and have learned already a lot from this group and I appreciate all your feedback and help!
Thanks in advance!

Accepted Answer

Steven Lord
Steven Lord on 11 Jun 2019
The retime function requires the first input to be a timetable array. From this line of code:
Power_Ah=Dataclean_interpolated.InverterEnergy./Dataclean_interpolated.BatteryVoltage;
I suspect Dataclean_interpolated is your timetable. If so I'd store Power_Ah as a new variable in that timetable then call retime on the timetable.
Dataclean_interpolated.Power_Ah = Dataclean_interpolated.InverterEnergy./Dataclean_interpolated.BatteryVoltage;
Alternately you could call groupsummary on your data with the times from your timetable as the groupvars input. See the "Group Operations with Vector Data" example on the groupsummary documentation page I linked earlier for an example you could adapt to your problem.
  1 Comment
Abm
Abm on 12 Jun 2019
Thank you so much Steven! I stored the Power_Ah in the time table and the problem is fixed :) I wanted to learn how to use the groupsummary method also but it doesnt work to calculate the total daily load, if you have time could you suggest how to write the line code for it? if not, I am satisfied with the alternative solution and thank you again!
Best regards!

Sign in to comment.

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!