

Hi. I am working on vector inputs to an expression. 'Th' also becomes a vector as output. I want to get 'th' less than 10 but greater than 0. Although I tried to use while loop but it didn't work. How can I get beta and Z as optimum scalar value that generate whole vector 'th' with values less than 10. Below is the code:
a=readtable('Book1.xlsx');
Lat=31.39;
local_long=74.238416;
St_long=75;
long_corr = -4*(St_long - loc al_long);
Solar_altitude = 6;
cosine_h=cos(a.Hour_Angle*pi/180);
sine_h=sin(a.Hour_Angle*pi/180);
cosine_L=cos(Lat*pi/180);
sine_L=sin(Lat*pi/180);
cosine_decl=cos(a.Declination_Angle*pi/180);
sine_decl=sin(a.Declination_Angle*pi/180);
a=addvars(a,cosine_h,'After','Hour_Angle');
a=addvars(a,sine_h,'After','cosine_h');
a=addvars(a,cosine_decl,'After','sine_h');
a=addvars(a,sine_decl,'After','cosine_decl');
n=length(a.Day_Number);
F=sine_decl*sine_L;
G=sine_decl*cosine_L;
H=cosine_decl.*cosine_h*cosine_L;
I=cosine_decl.*cosine_h*sine_L;
J=cosine_decl.*sine_h;
FH = F + H;
IG = I - G;
b=table();
b=addvars(b,FH);
b=addvars(b,IG,'After','FH');
b=addvars(b,J,'After','IG');
beta=45; % Collector Tilt angle
Z=20; % Collector aziuth angle
th= (180/pi*acos(FH*cos(beta*pi/180) + b.IG*sin(beta*pi/180)*cos(Z*pi/180) + b.J*sin(beta*pi/180)*sin(Z*pi/180)));
while th>25
C1 = 0;
B1 = 90;
C2 = -90;
beta = (B1-C1).*rand(1,1) + C1; % Optimum Collector Tilt angle
Z = (B1+C2).*rand(1,1) + C2; % Optimum Collector aziuth angle
th= 180/pi*acos(b.FH*cos(beta*pi/180) + b.IG*sin(beta*pi/180)*cos(Z*pi/180) + b.J*sin(beta*pi/180)*sin(Z*pi/180));
end


Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!