function [ absorption ] = solar_rad( nc,lat,t,I)%Calculating absorbed solar radiation
% Calculating the absorbed solar radiaiton as a function of time of
% day and year, cloud cover, and latitude, using a time step of one hour.
%BEGIN
for I=1:365; for T=[0:24]; t=T*3600; end delta=-23.45*(pi/180)*cosd(2*pi)/365*(I+9); %Declination
S=1357+45*cosd((2*pi)/365)*(I); %Solar constant
for lat=0; sinh=max(sind(lat)*sind(delta)+cosd(lat)*cosd(delta)*cosd((2*pi/86400)*(t+43200))); m=1/sinh; %optical length
Cext=0.128-0.0253*(log(m)); %Extinction
end for h=asin(max(sind(lat)*sind(delta)+cosd(lat)*cosd(delta)*cosd((2*pi)/86400)*(t+43200))); i=(pi/2)-h; %angle of incidence
j=asin(0.75*sin(i)); %angle of reflection
r=0.5*abs((sin(i-j)^2/sin(i+j)^2)+(tan(i-j)^2)/(tan(i+j)^2)); %reflectance
endendfor nc=0:100; if h>0 Insd=S*(exp(-Cext*m))*(sin(h))*(1-(0.71*nc)); %direct incoming solar radiation at sea level
end if h<=0 Insd=0; end for Insg=0.52*nc*Insd; %global radiation
Q_sun=Insd*(1-r)+0.97*Insg; endend[absorption]=solar_rad(0,0,t,I);
Whenever I run it I get this error message:
Error in solar_rad (line 7)for I=1:365;Output argument "absorption" (and maybe others) not assigned during call to "\\fs-home-k\home-005\osp42f\MyDocuments\MATLAB\Programmes\solar_rad.m>solar_rad".
Best Answer