using what you have learnt in the last several labs it is de
Solution
Rl = 0:0.1:40;
P = Rl.*(10.0./(Rl + 20.0)).^2;
figure
plot (Rl, P);
title(\'Plot of Rl vs P\');
xlabel(\'Rl\');
ylabel(\'P\');
grid on
value = 0;
for rl=0:0.001:40
prev_value = value;
value = rl*(10.0/(rl + 20.0))^2;
if value<prev_value
max = prev_value;
break;
end
end
fprintf(\'Maximum value: %f\ \', max);
BOS = [2.67 1.00 1.21 3.09 3.43 4.71 3.88 3.08 4.10 2.62 1.01 5.93];
SEA = [6.83 3.63 7.20 2.68 2.05 2.96 1.04 0.00 0.03 6.71 8.28 6.85];
total = 0;
num_months_bos = 0;
num_months_sea = 0;
bos_lower_sea_months = [];
bos_lower_sea = 0;
for i=1:1:12
total = total + BOS(i) + SEA(i);
end
av = total/12.0;
for i=1:1:12
if (BOS(i) > av)
num_months_bos = num_months_bos + 1;
end
if (SEA(i) > av)
num_months_sea = num_months_sea + 1;
end
if (BOS(i) < SEA(i))
bos_lower_sea = bos_lower_sea + 1;
bos_lower_sea_months(end+1) = i;
end
end
fprintf(\'Total precipitation: %f\ \', total);
fprintf(\'Number of months precipitaion in BOS greater than average: %f\ \', num_months_bos);
fprintf(\'Number of months precipitaion in SEA greater than average: %f\ \', num_months_sea);
fprintf(\'Number of months precipitaion in BOS lower than in SEA: %f\ \', bos_lower_sea);
