You are on page 1of 3

clc;

clear all;
lat = input('Enter the latitude:');
long=input('Enter the longitude:');
tilt_angle=input('Enter the tilt angle:');
time=input('Enter the time. Example for 2pm enter 1400:');
Llocal=input('Enter the local timemmeridian in degrees:');
date_n=input('Enter the day of the year, example for 10th Jan, Please enter 10:');
m=input('Enter the month of the year. Example for May. Please enter 5"');

date_1=0;

%%%%%%%%%%%%%%Table for A B and C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%

A = [0 1202 1187 1164 1130 1106 1092 1093 1107 1136 1136 1190 1204];
B = [0 0.141 0.142 0.149 0.164 0.177 0.185 0.186 0.182 0.165 0.152 0.144 0.141];
C = [0 0.103 0.104 0.109 0.120 0.130 0.137 0.138 0.134 0.121 0.111 0.106 0.103];
Month = [0 31 28 31 30 31 30 31 31 30 31 30 31];

%%%%%%%%%%%%%%%%%%%%%%%date calci%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
for i = 0:(m-1)
date_1 = Month(i) + date_1;
end

date = date_1+date_n;

%%%%%%%%%%%%%%%%Calculate z%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
z=((date-1)*(360/365));

%%%%%%%%%%Calculate the Equation of time%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%

Et=229.18*(0.000075+0.001868*cos(z)-0.032077*sin(z)-0.014615*cos(2*z)-
0.04089*sin(2*z));

%%%%%%%%%%%%%%%%Calculate local solar time%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%

lat_p= (time + (4*(81.44-Llocal)) + Et );


lat_n= (time - (4*(81.44-Llocal)) + Et );

%%%%%%Use the required lat_p or lat_n for following calculation%%%%%%%%%%%%%%%%%%%%


%%%%%%%%

%%%%%%%%%%%%%%%%%Calculate hour angle%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%
w= (lat_p-720)/4;

%%%%%%%%d calculation of declination angle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%

d1=(360/365)*(284+date);
d=(23.45*sin(d1));

%%%%%%%%%%%%%%%%%%%%%%%Calculation of incidence angle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%

Ii= sin(d)*sin(lat-tilt_angle) + cos(d)*cos(w)*cos(lat-tilt_angle);

%%%%%%%%%%%%%%%%%%%%%%Calculation of Ib%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%
m_exp_cal = -(B(m)/Ii);

Ibn_exp= exp(m_exp_cal);

Ibn=A(m)*Ibn_exp;

Ib=Ibn*Ii;

%%%%%%%%%%%%%%%%%%%%%%%Calculation of Id%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%

Id=(C(m)*Ibn);

%%%%%%%%rb calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%

rb_num= (sin(d)*sin(lat-tilt_angle)) + (cos(d)*cos(w)*cos(lat-tilt_angle));


rb_denom = (sin(d)*sin(lat)) + (cos(d)*cos(w)*cos(lat));

rb=rb_num/rb_denom;

%%%%%%%%%%rd calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%

rd=(((1+cos(tilt_angle)))/2);

%%%%%%%%%%%%%%%%%Rr calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%

Rr=0.6*((1-cos(tilt_angle))/2);

%%%%%%%%%%%%%%%%%%%%%%%%%%Calculation of It%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%

Ir=Ib+Id;

It=Ib*rb + Id*rd + Ir*Rr;

You might also like