%
% Load your data into MATLAB.
% Calculate the utilization ratio for each hour using the formula: Utilization Ratio = (Total Energy Consumed) / (Total Energy Generated).
% Plot the utilization ratio against time (hour).
% Sample data (replace with your actual data)
hours = 1:24; % Hours of the day
energy_consumed = [10, 15, 20, 18, 22, 25, 30, 35, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10]; % Energy consumed in kWh for each hour
energy_generated = [12, 14, 18, 20, 25, 28, 32, 36, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8]; % Energy generated in kWh for each hour
% Calculate utilization ratio
utilization_ratio = energy_consumed ./ energy_generated;
% Plot
figure;
plot(hours, utilization_ratio, '-o', 'LineWidth', 1.5);
xlabel('Hour of the Day');
ylabel('Utilization Ratio');
title('Hourly Utilization Ratio in the Microgrid');
grid on;