data = load('Ex8_data.txt'); T_air = data(:,1); % Air temperature T_min = T_air.*(-55/41) + 45; % Minimum temperature of heating water D_heat = data(:,2); % Demand of heat (kWh) P_in = zeros(length(D_heat),1); P_max = 5; % Target maximum of the electricity taken from the grid c = 4.19; % Specific heat capacity of water T_max = 95; % Maximum temperature of the water storage m = [100,500,1000]; % Masses of water P = zeros(length(P_in),3); sums = zeros(4,1); sums(1) = sum(D_heat); % Total heat demand (= electricity taken from grid if no heat storage) plot(D_heat); % Plots heat demand for j = 1:3 % Goes through cases m_water = {100, 500, 1000} kg T = 90; % Initial temperature of water for i = 1:length(D_heat) Q_loss = (T-20)*0.001; % Loss if (D_heat(i) < P_max) % If demand < 5kW % TODO: Insert necessary formulas here C_load =; % The amount of energy needed to reach T_max Q_in =; % The amount of electricity used to heat the storage P_in(i) =; % Total electricity taken from the grid T =; % New water temperature else % If demand > 5 kW % TODO: Insert necessary formulas here C_use =; % Capacity available for heating Q_out =; % The amount of heat taken from the storage P_in(i) =; % The amount of electricity taken from the grid T =; % New water temperature end end sums(j+1) = sum(P_in); % Total electricity taken from the grid P(:,j) = P_in; figure; plot(P(:,j)); % Plots the electricity taken from the grid ylabel('P_in (kW)') xlabel('Hour') end