Solar Assignment With MATLAB Code
Solar Assignment With MATLAB Code
Code
Exercise 1: Variation of Rd and Rr with Inclination Angle β (0°–90°)
This exercise analyzes how the diffuse radiation (Rd) and reflected radiation (Rr)
components vary as the surface inclination β changes. The relations used are:
- Rd = (1 + cos(β)) / 2
- Rr = ρ * (1 - cos(β)) / 2, where ρ is the ground reflectivity.
MATLAB Code:
Rd = (1 + cos(beta_rad)) / 2;
Rr = rho * (1 - cos(beta_rad)) / 2;
figure;
plot(beta, Rd, 'b-', 'LineWidth', 2);
hold on;
plot(beta, Rr, 'r--', 'LineWidth', 2);
xlabel('Inclination Angle β (degrees)');
ylabel('Rd and Rr');
legend('Rd', 'Rr');
title('Variation of Rd and Rr with Inclination Angle β');
grid on;
MATLAB Code:
N = 1:180;
phi_values = deg2rad([15 30 45 60]);
beta = deg2rad(30);
omega = deg2rad(0);
for i = 1:length(N)
delta = deg2rad(23.45) * sin(deg2rad(360 * (284 + N(i)) / 365));
for j = 1:length(phi_values)
cos_theta = sin(delta) * sin(phi_values(j) - beta) + ...
cos(delta) * cos(omega) * cos(phi_values(j) - beta);
cos_theta_z = sin(phi_values(j)) * sin(delta) + ...
cos(phi_values(j)) * cos(delta) * cos(omega);
Rb_all[j, i] = cos_theta / cos_theta_z;
end
end
figure;
plot(N, Rb_all);
xlabel('Day of the Year');
ylabel('Rb');
legend('15°', '30°', '45°', '60°');
title('Variation of Rb with Day of Year for Different Latitudes');
grid on;