Professional Documents
Culture Documents
Part 2
Part 2
if isempty(indices)
disp('Data for the entered year is not available.');
else
% Filter data for the entered year
year_months = months(indices);
year_rainfall = rainfall(indices);
year_max_temp = max_temp(indices);
% Calculate average maximum temperatures and total rainfall for each month of
the entered year
monthly_avg_max_temp = accumarray(year_months, year_max_temp, [], @mean);
monthly_total_rainfall = accumarray(year_months, year_rainfall, [], @sum);
% Plot average maximum temperatures for each month of the entered year
figure;
subplot(2, 1, 1);
bar(monthly_avg_max_temp);
title('Average Maximum Temperatures for Each Month');
xlabel('Month');
ylabel('Temperature (C)');
xticks(1:12);