Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
31 views2 pages

Matlab Code

This MATLAB code calculates the total solar radiation on a flat plate collector based on user inputs including day of the year, latitude, longitude, tilt angle, and azimuth angle. It computes various parameters such as solar angles and radiation components, and then plots the total radiation throughout the day. The output is a graph displaying the total solar radiation in watts per square meter against the hours of the day.

Uploaded by

shamikhahmed7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views2 pages

Matlab Code

This MATLAB code calculates the total solar radiation on a flat plate collector based on user inputs including day of the year, latitude, longitude, tilt angle, and azimuth angle. It computes various parameters such as solar angles and radiation components, and then plots the total radiation throughout the day. The output is a graph displaying the total solar radiation in watts per square meter against the hours of the day.

Uploaded by

shamikhahmed7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB CODE

clear; clc;
format short;

%% USER INPUT
n = input('Enter day of the year (1 to 365): ');
phi = input('Enter the latitude of the location (in degrees): ');
LL = input('Enter the longitude of the location (in degrees): ');
beta = input('Enter tilt angle of collector (in degrees): ');
gamma = input('Enter azimuth angle of collector (in degrees): ');

%% CONSTANTS & CONVERSIONS


rho = 0.2;
phi = deg2rad(phi);
beta = deg2rad(beta);
gamma = deg2rad(gamma);
delta = deg2rad(23.45 * sind((360/365)*(284 + n)));
B = deg2rad((360/365)*(n - 1));
E = 229.2 * (0.000075 + 0.001868*cos(B) - 0.032077*sin(B) ...
- 0.014615*cos(2*B) - 0.04089*sin(2*B));
GMT = ceil(LL/15);
SL = GMT * 15;
ST_LT = (E - 4 * (SL - LL)) / 60;

hours = 0:23;
omega = zeros(1, 24);
cos_theta = zeros(1, 24);
alpha_s = zeros(1, 24);
theta_z = zeros(1, 24);
m = zeros(1, 24);
A = zeros(1, 24);
k = zeros(1, 24);
IB = zeros(1, 24);
IBC = zeros(1, 24);
IDC = zeros(1, 24);
IRC = zeros(1, 24);
IC = zeros(1, 24);

for h = 1:24
ST = hours(h) + ST_LT;
omega(h) = deg2rad((ST - 12) * 15);
cos_theta(h) = sin(delta)*sin(phi)*cos(beta) ...
- sin(delta)*cos(phi)*sin(beta)*cos(gamma) ...
+ cos(delta)*cos(phi)*cos(beta)*cos(omega(h)) ...
+ cos(delta)*sin(phi)*sin(beta)*cos(gamma)*cos(omega(h));
cos_theta(h) = max(min(cos_theta(h), 1), -1);
alpha_s(h) = asin(cos(phi)*cos(delta)*cos(omega(h)) + sin(phi)*sin(delta));
theta_z(h) = acos(cos(phi)*cos(delta)*cos(omega(h)) + sin(phi)*sin(delta));
if alpha_s(h) > 0
m(h) = 1 / (sin(alpha_s(h)) + 0.50572 * (6.07995 + rad2deg(alpha_s(h)))^(-1.6364));
else
m(h) = Inf;
end
A(h) = 1160 + 75 * sin(deg2rad((360/365)*(n - 275)));
k(h) = 0.174 + 0.035 * sin(deg2rad((360/365)*(n - 100)));
IB(h) = A(h) * exp(-k(h) * m(h));
IBC(h) = IB(h) * cos_theta(h);
if IBC(h) < 0
IBC(h) = 0;
end
C = 0.095 + 0.04 * sin(deg2rad((360/365)*(n - 100)));
IDC(h) = C * IB(h) * (1 + cos(beta)) / 2;
IRC(h) = rho * IB(h) * (sin(alpha_s(h)) + C) * (1 - cos(beta)) / 2;
IC(h) = IBC(h) + IDC(h) + IRC(h);
end

figure;
plot(hours, IC, 'r-', 'LineWidth', 2);
xlabel('Hour of Day');
ylabel('Total Radiation on Collector (W/m^2)');
title(['Total Solar Radiation on Flat Plate Collector (Day ' num2str(n) ')']);
grid on;

You might also like