Subjects > MATLAB > Practice Test > Solar Calculator

MATLAB

Contents

% Author - J. Kadoko
% Class : **********
% Description : Solution for Problem 3, HW#3
% Determination of the total energy incident on a collector

% There is a function that calculates variables for each case
afternoon=true;
morning=false;
% 3(a) Declination angle of -23.45
% Afternoon
declination_Angle=deg2rad(-23.45); % Declination angle, given [degrees]
[E_a_1,time_a_1,elevation_Angle_a_1,incident_Angle_a_1]=...
    solarCalc(declination_Angle,afternoon);
% Morning
[E_a_2,time_a_2,elevation_Angle_a_2,incident_Angle_a_2]=...
    solarCalc(declination_Angle,morning);
% 3(b) Declination angle of 0
% Afternoon
declination_Angle=deg2rad(0); % Declination angle, given [degrees]
[E_b_1,time_b_1,elevation_Angle_b_1,incident_Angle_b_1]=...
    solarCalc(declination_Angle,afternoon);
% morning
[E_b_2,time_b_2,elevation_Angle_b_2,incident_Angle_b_2]=...
    solarCalc(declination_Angle,morning);
% 3(b) Declination angle of 23.45
% Afternoon
declination_Angle=deg2rad(23.45); % Declination angle, given [degrees]
[E_c_1,time_c_1,elevation_Angle_c_1,incident_Angle_c_1]=...
    solarCalc(declination_Angle,afternoon);
% Monring
[E_c_2,time_c_2,elevation_Angle_c_2,incident_Angle_c_2]=...
    solarCalc(declination_Angle,morning);

Plot all the variables for sanity check

subplot(2,2,1)

plot(abs(time_a_1),E_a_1,'-x'); hold on
plot(abs(time_a_2),E_a_2,'--');

legend('Afternoon', 'Morning')
title '3 (a) Cumulative Energy vs Time in the afternoon'
xlabel 'Time (minuntes away from noon)'
ylabel 'Cumulative energy*I (J/m2)'
grid on
hold off;

subplot(2,2,2);
plot(abs(time_b_1),E_b_1,'-x'); hold on
plot(abs(time_b_2),E_b_2,'--');
legend('Afternoon', 'Morning')
title '3 (b) Cumulative Energy vs Time in the afternoon'
xlabel 'Time (minutes away from noon)'
ylabel 'Cumulative energy*I (J/m2)'
grid on
hold off;

subplot(2,2,3);
plot(abs(time_c_1),E_c_1,'-x'); hold on
plot(abs(time_c_2),E_c_2,'--');
legend('Afternoon', 'Morning')
title '3 (c) Cumulative Energy vs Time in the afternoon'
xlabel 'Time (minutes away from noon)'
ylabel 'Cumulative energy*I (J/m2)'
grid on
hold off;
Scroll to Top