how to solve 'Index exceeds the number of array elements (1)'?

1 vue (au cours des 30 derniers jours)
Dan Williams
Dan Williams le 31 Oct 2018
Commenté : Star Strider le 31 Oct 2018
In a function, the error in the title appears with Error in sol_rad (line 13) dec = -(dec0)*(pi/180)*cos(wI(I+9)); coming up after it. How do I get around this?
function [Qsun] = sol_rad(t,I,nc,lat)
% t = Time of day (seconds) % I = Time of year (days) % nc = Cloud cover % lat = Latitude
wt = (2*pi)/86400; % Units: s-1 wI = (2*pi)/365; % Units: yr-1 dec0 = deg2rad(23.45);
% 2.1 dec = -(dec0)*(pi/180)*cos(wI(I+9));
% 2.2 sinh = max(0,sin(lat)*sin(dec)+cos(lat)*cos(dec)*cos(wt(t+43200))); h = asin(sinh);
% 2.3 S = 1357 + 45*cos(wI*I);
% 2.4 m = 1/sin(h);
% 2.5 Cext = 0.128 - 0.0235*ln(m);
% 2.6 if h > 0 Insd = S*e^(-Cext*m)*sin(h)*(1-0.71*nc); else Insd = 0; end
% 2.7 Insg = 0.52*nc*Insd;
% 2.8 i = (pi/2)-h;
% 2.9 j = arcsin(0.75*sin(i));
% 2.10 r = 0.5*((sin(i-j)^2/(sin(i+j)^2))+((tan(i-j)^2)/(tan(i+j)^2))); if r < 0 r = r*-1; end
% 2. Qsun = Insd(1-r) + 0.97*Insg

Réponse acceptée

Star Strider
Star Strider le 31 Oct 2018
You need an operator here (I chose ‘*’ for multiplication):
dec = -(dec0)*(pi/180)*cos(wI*(I+9));
  2 commentaires
Dan Williams
Dan Williams le 31 Oct 2018
Cheers bro!
Star Strider
Star Strider le 31 Oct 2018
Cheers!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by