the matrix only works till days= 16 then when the days=17 or bigger the output is 0 on all the values in the matrix

1 回表示 (過去 30 日間)
% solar irradiation on a HORIZONTAL SURFACE
Cn = 0.7; % Clearance index
I0 = 1353; % Solar constant
latitude = -34.005133; % Latitude of the location
days =31; % Number of days in the month
hours = 24; % Number of hours in a day
% Initialize matrices to store results
dec_deg = zeros(days, 1); % Declination angles in degrees
DNI = zeros(days, hours); % Direct Normal Irradiation
DHI = zeros(days, hours); % Diffuse Horizontal Irradiance
GHI = zeros(days, hours); % Global Horizontal Irradiance
for n = 1:days
% Calculate declination angle for the day (in degrees)
dec_deg(n) = 23.45 * sind((360/365) * (n + 284));
% Convert declination angle from degrees to radians
dec_rad = deg2rad(dec_deg(n));
for time = 1:hours
% Calculate hour angle
h = (12 - time) * 15; % Hour angle in degrees
h_rad = deg2rad(h); % Hour angle in radians
% Calculate diffuse factor (Cs)
Cs = 0.095 + 0.04 * sin(deg2rad(360/365) * (n - 100));
% Calculate extraterrestrial solar irradiation (I)
I = I0 * (1 + 0.034 * cos(deg2rad(360 * n / 365.25)));
% Calculate atmospheric optical depth (k)
k = 0.174 + 0.035 * sin(deg2rad((360/365) * (n - 100)));
% Calculate solar altitude angle (alt)
Lat = deg2rad(latitude); % Latitude angle in radians
alt = asin(cos(Lat) * cos(dec_rad) * cos(h_rad) + (sin(Lat) * sin(dec_rad)));
alt_deg = rad2deg(alt); % Daily Solar Altitude Angle
% Calculate air mass (AM)
AM = 1 / sin(deg2rad(alt_deg)); % Air Mass
% Calculate Direct Normal Irradiation (DNI) for the current hour
DNI(n, time) = Cn * I * exp(-k * AM);
% Calculate Diffuse Horizontal Irradiance (DHI) for the current hour
DHI(n, time) = Cs * DNI(n, time);
% Calculate Global Horizontal Irradiance (GHI) for the current hour
GHI(n, time) = (DNI(n, time) + DHI(n, time)) / 1000;
end
end
%% Format changed
format longg
% Display matrices
disp("Direct Normal Irradiation (DNI) for 31 days (24 hours each): ");
Direct Normal Irradiation (DNI) for 31 days (24 hours each):
disp(DNI);
Columns 1 through 7 1281.2228361481 1341.97549234377 1511.63517675545 2303.34464237454 1.34704967051447 517.820089333432 700.673875425726 1280.24350815717 1340.65618433303 1509.11776066271 2290.77534061806 1.02688338427038 516.888017417804 700.445615810866 1279.21846936815 1339.27474381777 1506.47843654145 2277.60738436809 0.744323769579973 515.828209260733 700.163111596337 1278.14911823906 1337.83325731683 1503.7222572551 2263.88753081884 0.50728585214361 514.639343733338 699.826056653587 1277.03690038159 1336.33388047711 1500.85443004571 2249.66308043351 0.320206790784969 513.319994560523 699.43412637029 1275.88330378205 1334.7788301891 1497.88029275599 2234.9815176941 0.183324446159025 511.868628038336 698.986977427737 1274.68985397857 1333.17037665311 1494.80529013152 2219.89017142442 0.0924128755815845 510.283600599962 698.48424755914 1273.45810922295 1331.51083544711 1491.63495038487 2204.43589812904 0.0392689552301415 508.563156231145 697.92555528866 1272.18965565481 1329.8025596452 1488.3748621921 2188.66479108488 0.0131603124953579 506.705423736689 697.310499651023 1270.88610251459 1328.04793203345 1485.03065227934 2172.62191721661 0.00312559751648933 504.708413860704 696.63865989157 1269.54907742064 1326.24935746696 1481.60796374291 2156.35108310282 0.000437928431823927 502.570016264489 695.909595146592 1268.18022173407 1324.4092554089 1478.11243523132 2139.89463081422 2.56909795258201e-05 500.287996367475 695.122844103851 1266.78118603351 1322.53005268913 1474.54968110145 2123.29326369127 3.06081326327697e-07 497.859992058434 694.277924643157 1265.35362571997 1320.61417651618 1470.92527264526 2106.5859016372 1.18162618092566e-10 495.283510286377 693.374333456924 1263.89919677039 1318.66404777276 1467.24472046641 2089.8095650404 2.42098533580544e-18 492.555923543116 692.41154565063 1262.41955165617 1316.68207462137 1463.51345807037 2072.99928605054 1.46810418433709e-51 489.674466252652 691.389014323119 1260.91633544124 1314.67064644223 1459.73682671544 2056.18804561777 3.23735416318532e+83 486.636231086222 690.306170126747 1259.39118207211 1312.63212812248 1455.92006155696 2039.40673446073 3.07612461418232e+25 483.438165226292 689.162420807346 1257.8457108703 1310.56885471136 1452.06827910228 2022.68413595456 7.85155024252415e+15 480.077066608052 687.957150724062 1256.28152323568 1308.4831264527 1448.18646598064 2006.04692881874 905098094103.915 476.549580173229 686.689720349125 1254.70019956703 1306.37720420222 1444.27946901951 1989.51970743031 6523545778.85771 472.852194178479 685.359465747679 1253.10329640464 1304.25330523409 1440.35198660758 1973.12501758394 294920219.785174 468.981236609425 683.965698037806 1251.49234379767 1302.11359943766 1436.40856131436 1956.88340555872 35335967.2949498 464.932871761905 682.507702830973 1249.86884289734 1299.96020590256 1432.45357372736 1940.81347842548 7554728.4670917 460.703097064363 680.984739653149 1248.23426377552 1297.79518988755 1428.49123746021 1924.93197363053 2342923.92242403 456.287740230078 679.396041346939 1246.59004346677 1295.62056016599 1424.52559527859 1909.25383601504 935792.860363488 451.682456845331 677.74081345511 1244.93758423038 1293.43826673855 1420.56051628531 1893.79230056813 447411.076482079 446.882728520344 676.018233586011 1243.27825202801 1291.25019890205 1416.59969410215 1878.55897936019 244185.234907306 441.883861754343 674.227450761439 1241.613375211 1289.05818366114 1412.64664598261 1863.56395125625 147317.594572228 436.68098769526 672.367584747616 1239.94424341102 1286.86398446861 1408.7047127879 1848.81585316349 96055.2861001032 431.269063009159 670.437725370068 1238.27210662622 1284.66930027859 1404.77705975729 1834.32197171896 66596.4511515789 425.642872115573 668.43693181328 Columns 8 through 14 776.427340998946 814.917604168974 835.827985157277 846.456100702558 849.730530357533 846.456100702558 835.827985157277 776.362885521887 814.906334365559 835.837054118668 846.473193298117 849.749780478129 846.473193298117 835.837054118668 776.264436356852 814.86900794568 835.823719408693 846.469562361797 849.748800828432 846.469562361797 835.823719408693 776.131847885237 814.805523395645 835.787896493851 846.445130630707 849.727516236599 846.445130630707 835.787896493851 775.964969674804 814.715777919408 835.729500789325 846.399821269355 849.685852088264 846.399821269355 835.729500789325 775.763646469998 814.599667468026 835.648447699808 846.333557914439 849.623734372343 846.333557914439 835.648447699808 775.527718177829 814.457086766989 835.544652658789 846.246264718291 849.541089725542 846.246264718291 835.544652658789 775.257019849348 814.287929341399 835.418031166261 846.137866390929 849.437845475515 846.137866390929 835.418031166261 774.951381656745 814.092087539025 835.268498824833 846.008288240688 849.313929682655 846.008288240688 835.268498824833 774.610628866135 813.869452551238 835.095971374252 845.857456213414 849.169271180471 845.857456213414 835.095971374252 774.234581806076 813.619914431876 834.900364724323 845.685296930201 849.003799614563 845.685296930201 834.900364724323 773.823055831927 813.343362114076 834.681594986262 845.49173772369 848.817445480168 845.49173772369 834.681594986262 773.375861286128 813.039683425133 834.439578502496 845.276706672928 848.610140158302 845.276706672928 834.439578502496 772.892803454525 812.708765099468 834.174231874966 845.040132636814 848.381815950506 845.040132636814 834.174231874966 772.373682518884 812.350492789789 833.885471991977 844.781945286177 848.132406112237 844.781945286177 833.885471991977 771.818293505729 811.96475107655 833.573216053661 844.502075134518 847.86184488493 844.502075134518 833.573216053661 771.226426231705 811.551423475832 833.237381596144 844.200453567494 847.570067526805 844.200453567494 833.237381596144 770.597865245633 811.110392445769 832.877886514496 843.877012871195 847.25701034246 843.877012871195 832.877886514496 769.932389767494 810.64153939168 832.494649084574 843.531686259319 846.922610711352 843.531686259319 832.494649084574 769.22977362456 810.144744670062 832.087587983885 843.164407899316 846.566807115231 843.164407899316 832.087587983885 768.48978518495 809.61988759164 831.656622311585 842.77511293764 846.18953916465 842.77511293764 831.656622311585 767.712187288876 809.06684642365 831.201671607777 842.363737524195 845.790747624642 842.363737524195 831.201671607777 766.896737177893 808.485498391587 830.722655872252 841.930218836136 845.370374439713 841.930218836136 830.722655872252 766.043186422489 807.875719680643 830.219495582855 841.474495101154 844.928362758256 841.474495101154 830.219495582855 765.151280848361 807.237385437079 829.692111713663 840.996505620406 844.464656956574 840.996505620406 829.692111713663 764.220760461769 806.570369769794 829.140425753161 840.496190791263 843.979202662634 840.496190791263 829.140425753161 763.251359374381 805.874545752381 828.56435972265 839.973492130055 843.471946779751 839.973492130055 828.56435972265 762.242805728038 805.149785425968 827.963836195097 839.428352294998 842.942837510373 839.428352294998 827.963836195097 761.194821619934 804.395959803148 827.338778314678 838.860715109529 842.39182438017 838.860715109529 827.338778314678 760.107123028692 803.612938873353 826.68910981726 838.270525586248 841.818858262626 838.270525586248 826.68910981726 758.97941974188 802.800591610016 826.014755052099 837.657729951704 841.223891404359 837.657729951704 826.014755052099 Columns 15 through 21 814.917604168974 776.427340998946 700.673875425726 517.820089333432 1.34704967051447 2303.34464237454 1511.63517675545 814.906334365559 776.362885521887 700.445615810866 516.888017417804 1.02688338427038 2290.77534061806 1509.11776066271 814.86900794568 776.264436356852 700.163111596337 515.828209260733 0.744323769579973 2277.60738436809 1506.47843654145 814.805523395645 776.131847885237 699.826056653587 514.639343733338 0.50728585214361 2263.88753081884 1503.7222572551 814.715777919408 775.964969674804 699.43412637029 513.319994560523 0.320206790784969 2249.66308043351 1500.85443004571 814.599667468026 775.763646469998 698.986977427737 511.868628038336 0.183324446159025 2234.9815176941 1497.88029275599 814.457086766989 775.527718177829 698.48424755914 510.283600599962 0.0924128755815845 2219.89017142442 1494.80529013152 814.287929341399 775.257019849348 697.92555528866 508.563156231145 0.0392689552301415 2204.43589812904 1491.63495038487 814.092087539025 774.951381656745 697.310499651023 506.705423736689 0.0131603124953579 2188.66479108488 1488.3748621921 813.869452551238 774.610628866135 696.63865989157 504.708413860704 0.00312559751648933 2172.62191721661 1485.03065227934 813.619914431876 774.234581806076 695.909595146592 502.570016264489 0.000437928431823927 2156.35108310282 1481.60796374291 813.343362114076 773.823055831927 695.122844103851 500.287996367475 2.56909795258201e-05 2139.89463081422 1478.11243523132 813.039683425133 773.375861286128 694.277924643157 497.859992058434 3.06081326327697e-07 2123.29326369127 1474.54968110145 812.708765099468 772.892803454525 693.374333456924 495.283510286377 1.18162618092566e-10 2106.5859016372 1470.92527264526 812.350492789789 772.373682518884 692.41154565063 492.555923543116 2.42098533580544e-18 2089.8095650404 1467.24472046641 811.96475107655 771.818293505729 691.389014323119 489.674466252652 1.46810418433709e-51 2072.99928605054 1463.51345807037 811.551423475832 771.226426231705 690.306170126747 486.636231086222 3.23735416318532e+83 2056.18804561777 1459.73682671544 811.110392445769 770.597865245633 689.162420807346 483.438165226292 3.07612461418232e+25 2039.40673446073 1455.92006155696 810.64153939168 769.932389767494 687.957150724062 480.077066608052 7.85155024252415e+15 2022.68413595456 1452.06827910228 810.144744670062 769.22977362456 686.689720349125 476.549580173229 905098094103.915 2006.04692881874 1448.18646598064 809.61988759164 768.48978518495 685.359465747679 472.852194178479 6523545778.85771 1989.51970743031 1444.27946901951 809.06684642365 767.712187288876 683.965698037806 468.981236609425 294920219.785174 1973.12501758394 1440.35198660758 808.485498391587 766.896737177893 682.507702830973 464.932871761905 35335967.2949498 1956.88340555872 1436.40856131436 807.875719680643 766.043186422489 680.984739653149 460.703097064363 7554728.4670917 1940.81347842548 1432.45357372736 807.237385437079 765.151280848361 679.396041346939 456.287740230078 2342923.92242403 1924.93197363053 1428.49123746021 806.570369769794 764.220760461769 677.74081345511 451.682456845331 935792.860363488 1909.25383601504 1424.52559527859 805.874545752381 763.251359374381 676.018233586011 446.882728520344 447411.076482079 1893.79230056813 1420.56051628531 805.149785425968 762.242805728038 674.227450761439 441.883861754343 244185.234907306 1878.55897936019 1416.59969410215 804.395959803148 761.194821619934 672.367584747616 436.68098769526 147317.594572228 1863.56395125625 1412.64664598261 803.612938873353 760.107123028692 670.437725370068 431.269063009159 96055.2861001032 1848.81585316349 1408.7047127879 802.800591610016 758.97941974188 668.43693181328 425.642872115573 66596.4511515789 1834.32197171896 1404.77705975729 Columns 22 through 24 1341.97549234377 1281.2228361481 1264.88423207535 1340.65618433303 1280.24350815717 1263.9881691836 1339.27474381777 1279.21846936815 1263.05032985571 1337.83325731683 1278.14911823906 1262.07195684528 1336.33388047711 1277.03690038159 1261.05433497382 1334.7788301891 1275.88330378205 1259.99878700799 1333.17037665311 1274.68985397857 1258.90666949614 1331.51083544711 1273.45810922295 1257.77936858807 1329.8025596452 1272.18965565481 1256.61829586142 1328.04793203345 1270.88610251459 1255.42488417715 1326.24935746696 1269.54907742064 1254.20058358535 1324.4092554089 1268.18022173407 1252.94685730175 1322.53005268913 1266.78118603351 1251.66517777362 1320.61417651618 1265.35362571997 1250.3570228525 1318.66404777276 1263.89919677039 1249.02387208966 1316.68207462137 1262.41955165617 1247.66720316844 1314.67064644223 1260.91633544124 1246.28848848621 1312.63212812248 1259.39118207211 1244.88919189667 1310.56885471136 1257.8457108703 1243.47076562207 1308.4831264527 1256.28152323568 1242.0346473426 1306.37720420222 1254.70019956703 1240.58225746925 1304.25330523409 1253.10329640464 1239.11499660428 1302.11359943766 1251.49234379767 1237.6342431924 1299.96020590256 1249.86884289734 1236.141351364 1297.79518988755 1248.23426377552 1234.63764897048 1295.62056016599 1246.59004346677 1233.12443581066 1293.43826673855 1244.93758423038 1231.60298204572 1291.25019890205 1243.27825202801 1230.07452679941 1289.05818366114 1241.613375211 1228.54027693907 1286.86398446861 1239.94424341102 1227.00140603226 1284.66930027859 1238.27210662622 1225.45905347294
disp("Diffuse Horizontal Irradiance (DHI) for 31 days (24 hours each): ");
Diffuse Horizontal Irradiance (DHI) for 31 days (24 hours each):
disp(DHI);
Columns 1 through 7 70.922650553431 74.2856404127999 83.6772264593852 127.502650254326 0.074566523765089 28.6641575604076 38.7861088771546 70.758707946641 74.0977000075781 83.4085251777838 126.610525470644 0.056755563312668 28.5682591105119 38.7134372842933 70.60747087292 73.9223242388446 83.1512637409948 125.714333323494 0.0410835366585965 28.471544253733 38.6460543621998 70.4690183742228 73.7596224463949 82.9056875008675 124.816369021355 0.0279685175427278 28.3739423296769 38.5839606203581 70.3434240182858 73.6096981663672 82.6720351862038 123.918896875987 0.0176380510625739 28.2753662197587 38.5271493011853 70.2307557952345 73.4726489372358 82.4505381794778 123.024136071656 0.0100910595595429 28.1757120799686 38.4756063272086 70.1310760249966 73.3485661217984 82.2414198383845 122.134247710052 0.00508438533724268 28.0748590539786 38.4293102474605 70.0444412757405 73.2375347457614 82.0448948657039 121.251323223229 0.00215992344676002 27.9726689662166 38.3882321830631 69.9709022934874 73.1396333533866 81.8611687303201 120.377374214203 0.000723822061963304 27.8689859945538 38.3523357719736 69.910503942963 73.0549338805148 81.6904371415958 119.514323753805 0.000171936806192382 27.7636363222804 38.3215771128562 69.8632851596846 72.9835015451417 81.5328855786604 118.66399913368 2.40992014063836e-05 27.6564277690857 38.2959047080448 69.8292789132084 72.9253947555849 81.3886888755568 117.82812604953 1.41461169644246e-06 27.5471494008208 38.2752594055586 69.8085121813918 72.880665036151 81.258010862592 117.008324166206 1.6867223979184e-08 27.4355711178991 38.259574340127 69.801005935468 72.8493569700878 81.1410040636846 116.206103997281 6.51823287907894e-12 27.3214432222994 38.2487748731822 69.8067751356669 72.8315081594947 81.0378094489766 115.422865016381 1.337141279741e-19 27.2044959632658 38.2427785317708 69.825828737069 72.827149201758 80.9485562415065 114.659894905727 8.12024744144772e-53 27.0844390619718 38.2414949463375 69.8581697053278 72.8363036819854 80.8733617763141 113.918369839001 1.79358162132867e+82 26.9609612156275 38.2448257873304 69.9037950418581 72.8589881808289 80.8123314099719 113.199355690396 1.70743441445427e+24 26.8337295817717 38.252664700577 69.9626958180494 72.8952122970148 80.7655584782182 112.5038100594 436711447652652 26.7023892438138 38.2648972413774 70.0348572180359 72.944978683836 80.7331242990977 111.832585001047 50457174300.885 26.5665626592884 38.2814008072629 70.1202585895303 73.0082830988133 80.7150982187973 111.186430353737 364575312.167793 26.4258490927661 38.3020445693667 70.2188735022081 73.0851144656921 80.7115376972023 110.56599756085 16526144.0663 26.2798240359528 38.3266894023536 70.3306698131188 73.1754549479104 80.7224884300766 109.971843887981 1985791.012358 26.1280386182195 38.3551878128594 70.4556097385903 73.2792800326578 80.7479845047015 109.404436944248 425863.084421371 25.970019011661 38.3873838663876 70.5936499320917 73.396558624632 80.7880485857758 108.864159423525 132503.614102737 25.8052658358208 38.42311311262 70.7447415675172 73.5272531485995 80.842692128388 108.351313989358 53106.8127923064 25.6332535684624 38.4622025090953 70.9088304273643 73.6713196598742 80.9119156149144 107.866128235376 25483.5234757611 25.4534299702714 38.5044703432185 71.085856995284 73.8287079618407 80.9957088127687 107.408759661146 13961.5702765382 25.2652155331721 38.5497261525676 71.2757565524952 73.9993617296682 81.0940510500256 106.979300611331 8456.87813635621 25.0680029641121 38.5977706434712 71.4784592775713 74.18321863939 81.2069115060647 106.577783133648 5537.25209208926 24.8611567187688 38.6483956078393 71.6938903491214 74.3802105015493 81.3342495145143 106.204183718321 3855.82348253858 24.6440126027569 38.7013838382375 Columns 8 through 14 42.979475101576 45.1101204565437 46.2676237431938 46.8559477283684 47.0372052142869 46.8559477283684 46.2676237431938 42.9093639821141 45.0396498399284 46.1964849862789 46.7843414847365 46.9654375604869 46.7843414847365 46.1964849862789 42.8465269164092 44.9773366485155 46.1339484507246 46.7215541367184 46.9025542864682 46.7215541367184 46.1339484507246 42.7909769439081 44.9231975989569 46.0800322861563 46.6676044383346 46.8485743175702 46.6676044383346 46.0800322861563 42.7427217403512 44.8772446618008 46.0347501478205 46.6225067566651 46.8035122226486 46.6225067566651 46.0347501478205 42.7017635927634 44.8394850432175 45.9981111807834 46.5862710570859 46.767378199607 46.5862710570859 45.9981111807834 42.6680993759097 44.8099211685678 45.9701200060529 46.5589028904482 46.7401780628765 46.5589028904482 45.9701200060529 42.6417205302324 44.7885506678355 45.9507767086473 46.5404033822236 46.7219132328637 46.5404033822236 45.9507767086473 42.6226130412903 44.7753663629462 45.9400768276319 46.5307692236352 46.7125807273879 46.5307692236352 45.9400768276319 42.6107574207149 44.7703562569938 45.9380113481428 46.5299926647941 46.7121731551265 46.5299926647941 45.9380113481428 42.6061286887023 44.7735035253929 45.9445666954189 46.5380615098595 46.7206787110881 46.5380615098595 45.9445666954189 42.6086963580556 44.7847865089792 45.9597247308586 46.5549591142425 46.7380811741287 46.5549591142425 45.9597247308586 42.6184244197948 44.8041787090743 45.9834627501218 46.580664383867 46.7643599065312 46.580664383867 45.9834627501218 42.6352713303475 44.8316487845344 46.0157534832914 46.615151776508 46.7994898556601 46.615151776508 46.0157534832914 42.659190000338 44.8671605508006 46.0565650971122 46.6583913052179 46.8434415577089 46.6583913052179 46.0565650971122 42.6901277849869 44.910672980966 46.1058611993228 46.7103485438592 46.8961811435528 46.7103485438592 46.1058611993228 42.7280264761378 44.9621402088791 46.1636008450927 46.7709846347542 46.9576703467198 46.7709846347542 46.1636008450927 42.7728222959243 45.0215115342962 46.2297385455823 46.8402562984645 47.0278665134928 46.8402562984645 46.2297385455823 42.8244458920933 45.0887314301009 46.3042242786352 46.9181158457137 47.1067226151524 46.9181158457137 46.3042242786352 42.8828223349994 45.163739551605 46.3870035016177 47.0045111914619 47.1941872623728 47.0045111914619 46.3870035016177 42.9478711162846 45.2464707479466 46.4780171664174 47.0993858711433 47.2902047217782 47.0993858711433 46.4780171664174 43.0195061492629 45.336855075599 46.5772017366103 47.2026790590761 47.3947149346696 47.2026790590761 46.5772017366103 43.0976357710234 45.4348178140082 46.6844892068105 47.3143255890537 47.5076535379301 47.3143255890537 46.6844892068105 43.1821627462732 45.5402794833709 46.79980712421 47.434255977124 47.6289518871152 47.434255977124 46.79980712421 43.2729842729383 45.6531558645713 46.9230786123218 47.5623964465665 47.7585370817358 47.5623964465665 46.9230786123218 43.3699919895443 45.7733580212909 47.0542223969338 47.6986689550724 47.8963319927391 47.6986689550724 47.0542223969338 43.4730719844006 45.9007923243083 47.1931528342858 47.8429912241359 48.0422552921947 47.8429912241359 47.1931528342858 43.5821048066131 46.0353604780056 47.3397799414781 47.9952767706621 48.1962214851897 47.9952767706621 47.3397799414781 43.6969654789539 46.1769595491001 47.4940094291225 48.1554349407988 48.358140943939 48.1554349407988 47.4940094291225 43.8175235126185 46.325481997619 47.6557427362461 48.3233709459976 48.5279199441155 48.3233709459976 47.6557427362461 43.9436429239048 46.4808157101383 47.8248770674581 48.4989859013106 48.7054607034044 48.4989859013106 47.8248770674581 Columns 15 through 21 45.1101204565437 42.979475101576 38.7861088771546 28.6641575604076 0.074566523765089 127.502650254326 83.6772264593852 45.0396498399284 42.9093639821141 38.7134372842933 28.5682591105119 0.056755563312668 126.610525470644 83.4085251777838 44.9773366485155 42.8465269164092 38.6460543621998 28.471544253733 0.0410835366585965 125.714333323494 83.1512637409948 44.9231975989569 42.7909769439081 38.5839606203581 28.3739423296769 0.0279685175427278 124.816369021355 82.9056875008675 44.8772446618008 42.7427217403512 38.5271493011853 28.2753662197587 0.0176380510625739 123.918896875987 82.6720351862038 44.8394850432175 42.7017635927634 38.4756063272086 28.1757120799686 0.0100910595595429 123.024136071656 82.4505381794778 44.8099211685678 42.6680993759097 38.4293102474605 28.0748590539786 0.00508438533724268 122.134247710052 82.2414198383845 44.7885506678355 42.6417205302324 38.3882321830631 27.9726689662166 0.00215992344676002 121.251323223229 82.0448948657039 44.7753663629462 42.6226130412903 38.3523357719736 27.8689859945538 0.000723822061963304 120.377374214203 81.8611687303201 44.7703562569938 42.6107574207149 38.3215771128562 27.7636363222804 0.000171936806192382 119.514323753805 81.6904371415958 44.7735035253929 42.6061286887023 38.2959047080448 27.6564277690857 2.40992014063836e-05 118.66399913368 81.5328855786604 44.7847865089792 42.6086963580556 38.2752594055586 27.5471494008208 1.41461169644246e-06 117.82812604953 81.3886888755568 44.8041787090743 42.6184244197948 38.259574340127 27.4355711178991 1.6867223979184e-08 117.008324166206 81.258010862592 44.8316487845344 42.6352713303475 38.2487748731822 27.3214432222994 6.51823287907894e-12 116.206103997281 81.1410040636846 44.8671605508006 42.659190000338 38.2427785317708 27.2044959632658 1.337141279741e-19 115.422865016381 81.0378094489766 44.910672980966 42.6901277849869 38.2414949463375 27.0844390619718 8.12024744144772e-53 114.659894905727 80.9485562415065 44.9621402088791 42.7280264761378 38.2448257873304 26.9609612156275 1.79358162132867e+82 113.918369839001 80.8733617763141 45.0215115342962 42.7728222959243 38.252664700577 26.8337295817717 1.70743441445427e+24 113.199355690396 80.8123314099719 45.0887314301009 42.8244458920933 38.2648972413774 26.7023892438138 436711447652652 112.5038100594 80.7655584782182 45.163739551605 42.8828223349994 38.2814008072629 26.5665626592884 50457174300.885 111.832585001047 80.7331242990977 45.2464707479466 42.9478711162846 38.3020445693667 26.4258490927661 364575312.167793 111.186430353737 80.7150982187973 45.336855075599 43.0195061492629 38.3266894023536 26.2798240359528 16526144.0663 110.56599756085 80.7115376972023 45.4348178140082 43.0976357710234 38.3551878128594 26.1280386182195 1985791.012358 109.971843887981 80.7224884300766 45.5402794833709 43.1821627462732 38.3873838663876 25.970019011661 425863.084421371 109.404436944248 80.7479845047015 45.6531558645713 43.2729842729383 38.42311311262 25.8052658358208 132503.614102737 108.864159423525 80.7880485857758 45.7733580212909 43.3699919895443 38.4622025090953 25.6332535684624 53106.8127923064 108.351313989358 80.842692128388 45.9007923243083 43.4730719844006 38.5044703432185 25.4534299702714 25483.5234757611 107.866128235376 80.9119156149144 46.0353604780056 43.5821048066131 38.5497261525676 25.2652155331721 13961.5702765382 107.408759661146 80.9957088127687 46.1769595491001 43.6969654789539 38.5977706434712 25.0680029641121 8456.87813635621 106.979300611331 81.0940510500256 46.325481997619 43.8175235126185 38.6483956078393 24.8611567187688 5537.25209208926 106.577783133648 81.2069115060647 46.4808157101383 43.9436429239048 38.7013838382375 24.6440126027569 3855.82348253858 106.204183718321 81.3342495145143 Columns 22 through 24 74.2856404127999 70.922650553431 70.0182199778206 74.0977000075781 70.758707946641 69.8602798150582 73.9223242388446 70.60747087292 69.7150576792162 73.7596224463949 70.4690183742228 69.5826258825354 73.6096981663672 70.3434240182858 69.4630513563499 73.4726489372358 70.2307557952345 69.356395565598 73.3485661217984 70.1310760249966 69.2627144330385 73.2375347457614 70.0444412757405 69.1820582733286 73.1396333533866 69.9709022934874 69.1144717370553 73.0549338805148 69.910503942963 69.0599937647464 72.9835015451417 69.8632851596846 69.0186575508291 72.9253947555849 69.8292789132084 68.9904905174418 72.880665036151 69.8085121813918 68.9755142979542 72.8493569700878 69.801005935468 68.9737447299939 72.8315081594947 69.8067751356669 68.9851918577351 72.827149201758 69.825828737069 69.0098599431587 72.8363036819854 69.8581697053278 69.0477474859577 72.8589881808289 69.9037950418581 69.0988472517246 72.8952122970148 69.9626958180494 69.1631463080324 72.944978683836 70.0348572180359 69.2406260679949 73.0082830988133 70.1202585895303 69.3312623408729 73.0851144656921 70.2188735022081 69.4350253892786 73.1754549479104 70.3306698131188 69.5518799925206 73.2792800326578 70.4556097385903 69.6817855156257 73.396558624632 70.5936499320917 69.8246959835717 73.5272531485995 70.7447415675172 69.9805601602669 73.6713196598742 70.9088304273643 70.1493216318183 73.8287079618407 71.085856995284 70.3309188936368 73.9993617296682 71.2757565524952 70.5252854409398 74.18321863939 71.4784592775713 70.7323498622249 74.3802105015493 71.6938903491214 70.9520359353028
disp("Global Horizontal Irradiance (GHI) for 31 days (24 hours each): ");
Global Horizontal Irradiance (GHI) for 31 days (24 hours each):
disp(GHI);
Columns 1 through 7 1.35214548670153 1.41626113275657 1.59531240321483 2.43084729262886 0.00142161619427956 0.54648424689384 0.73945998430288 1.35100221610381 1.41475388434061 1.59252628584049 2.41738586608871 0.00108363894758305 0.545456276528316 0.73915905309516 1.34982594024107 1.41319706805661 1.58962970028244 2.40332171769158 0.000785407306238569 0.544299753514466 0.738809165958537 1.34861813661329 1.41159287976322 1.58662794475596 2.3887038998402 0.000535254369686337 0.543013286063015 0.738410017273945 1.34738032439988 1.40994357864347 1.58352646523191 2.37358197730949 0.000337844841847543 0.541595360780282 0.737961275671475 1.34611405957729 1.40825147912633 1.58033083093547 2.35800565376575 0.000193415505718568 0.540044340118305 0.737462583754946 1.34482093000357 1.40651894277491 1.5770467099699 2.34202441913447 9.74972609188272e-05 0.538358459653941 0.736913557806601 1.34350255049869 1.40474837019287 1.57367984525057 2.32568722135227 4.14288786769015e-05 0.536535825197361 0.736313787471723 1.34216055794829 1.40294219299858 1.57023603092242 2.30904216529909 1.38841345573212e-05 0.534574409731243 0.735662835422997 1.34079660645755 1.40110286591396 1.56672108942093 2.29213624097042 3.29753432268171e-06 0.532472050182985 0.734960237004426 1.33941236258032 1.3992328590121 1.56314084932158 2.2750150822365 4.62027633230311e-07 0.530226444033575 0.734205499854637 1.33800950064728 1.39733465016448 1.55950112410687 2.25772275686375 2.71055912222625e-08 0.527835145768295 0.733398103509409 1.3365896982149 1.39541071772529 1.55580769196404 2.24030158785747 3.22948550306881e-10 0.525295563176333 0.732537498983284 1.33515463165544 1.39346353348626 1.55206627670895 2.22279200563449 1.24680850971645e-13 0.522604953508677 0.731623108330107 1.33370597190606 1.39149555593226 1.54828252991539 2.20523243005679 2.55469946377954e-21 0.519760419506382 0.730654324182401 1.33224538039324 1.38950922382313 1.54446201431187 2.18765918095627 1.54930665875157e-54 0.516758905314623 0.729630509269457 1.33077450514657 1.38750695012421 1.54061018849175 2.17010641545677 3.41671232531819e+80 0.513597192301849 0.728550995914078 1.32929497711396 1.3854911163033 1.53673239296693 2.15260609015113 3.24686805562775e+22 0.510271894808063 0.727415085507923 1.32780840668835 1.38346406700838 1.5328338375805 2.13518794601396 8288261690176.8 0.506779455851866 0.726222047965439 1.32631638045372 1.38142810513653 1.52891959027974 2.11787951381978 955555268.4048 0.503116142832518 0.724971121156388 1.32482045815656 1.37938548730103 1.5249945672383 2.10070613778404 6888121.0910255 0.499278043271245 0.723661510317046 1.32332216990685 1.37733841969978 1.52106352430478 2.08369101514479 311446.363851474 0.495261060645378 0.72229238744016 1.32182301361079 1.37528905438557 1.51713104974444 2.0668552494467 37321.7583073078 0.491060910380125 0.720862890643832 1.32032445263593 1.37323948593522 1.51320155823206 2.05021791536973 7980.59155151307 0.486673116076024 0.719372123519537 1.31882791370761 1.37119174851218 1.50927928604599 2.03379613305406 2475.42753652677 0.482093006065898 0.717819154459559 1.31733478503428 1.36914781331458 1.50536828740698 2.01760515000439 988.899673155794 0.477315710413793 0.716203015964205 1.31584641465775 1.36710958639843 1.50147243190023 2.0016584288035 472.89459995784 0.472336158490616 0.71452270392923 1.31436410902329 1.36507890686389 1.49759540291492 1.98596773902134 258.146805183844 0.467149077287515 0.712777176914006 1.31288913176349 1.36305754539081 1.49374069703263 1.97054325186758 155.774472708584 0.461748990659372 0.710965355391088 1.31142270268859 1.361047203108 1.48991162429397 1.95539363629713 101.592538192193 0.456130219727928 0.709086120977907 1.30996599697534 1.35904951078013 1.48611130927181 1.94052615543728 70.4522746341174 0.45028688471833 0.707138315651517 Columns 8 through 14 0.819406816100522 0.860027724625518 0.882095608900471 0.893312048430926 0.89676773557182 0.893312048430926 0.882095608900471 0.819272249504001 0.859945984205488 0.882033539104947 0.893257534782853 0.896715218038616 0.893257534782853 0.882033539104947 0.819110963273262 0.859846344594196 0.881957667859417 0.893191116498515 0.8966513551149 0.893191116498515 0.881957667859417 0.818922824829145 0.859728720994602 0.881867928780007 0.893112735069042 0.896576090554169 0.893112735069042 0.881867928780007 0.818707691415155 0.859593022581209 0.881764250937146 0.89302232802602 0.896489364310913 0.89302232802602 0.881764250937146 0.818465410062761 0.859439152511243 0.881646558880592 0.892919828971525 0.89639111257195 0.892919828971525 0.881646558880592 0.818195817553739 0.859267007935557 0.881514772664842 0.892805167608739 0.896281267788418 0.892805167608739 0.881514772664842 0.81789874037958 0.859076480009235 0.881368807874908 0.892678269773152 0.896159758708379 0.892678269773152 0.881368807874908 0.817573994698036 0.858867453901971 0.881208575652465 0.892539057464324 0.896026510410043 0.892539057464324 0.881208575652465 0.817221386286849 0.858639808808231 0.881033982722395 0.892387448878208 0.895881444335598 0.892387448878208 0.881033982722395 0.816840710494778 0.858393417957269 0.880844931419742 0.89222335844006 0.895724478325651 0.89222335844006 0.880844931419742 0.816431752189983 0.858128148623056 0.88064131971712 0.892046696837933 0.895555526654297 0.892046696837933 0.88064131971712 0.815994285705922 0.857843862134208 0.880423041252618 0.891857371056795 0.895374500064833 0.891857371056795 0.880423041252618 0.815528074784873 0.857540413884002 0.880189985358257 0.891655284413322 0.895181305806166 0.891655284413322 0.880189985358257 0.815032872519222 0.857217653340589 0.879942037089089 0.891440336591395 0.894975847669946 0.891440336591395 0.879942037089089 0.814508421290716 0.856875424057516 0.879679077252984 0.891212423678378 0.894758026028483 0.891212423678378 0.879679077252984 0.813954452707842 0.856513563684711 0.879400982441237 0.890971438202248 0.894527737873525 0.890971438202248 0.879400982441237 0.813370687541557 0.856131903980066 0.879107625060078 0.89071726916966 0.894284876855953 0.89071726916966 0.879107625060078 0.812756835659587 0.855730270821781 0.878798873363209 0.890449802105032 0.894029333326504 0.890449802105032 0.878798873363209 0.812112595959559 0.855308484221667 0.878474591485503 0.890168919090778 0.893760994377604 0.890168919090778 0.878474591485503 0.811437656301235 0.854866358339587 0.878134639478003 0.889874498808783 0.893479743886428 0.889874498808783 0.878134639478003 0.810731693438139 0.854403701499249 0.877778873344387 0.889566416583271 0.893185462559312 0.889566416583271 0.877778873344387 0.809994372948917 0.853920316205595 0.877407145079062 0.88924454442519 0.892878027977643 0.88924454442519 0.877407145079062 0.809225349168762 0.853415999164014 0.877019302707065 0.888908751078278 0.892557314645371 0.888908751078278 0.877019302707065 0.808424265121299 0.852890541301651 0.876615190325985 0.888558902066972 0.89222319403831 0.888558902066972 0.876615190325985 0.807590752451314 0.852343727791084 0.876194648150095 0.888194859746336 0.891875534655373 0.888194859746336 0.876194648150095 0.806724431358781 0.851775338076689 0.875757512556935 0.887816483354191 0.891514202071945 0.887816483354191 0.875757512556935 0.805824910534651 0.851185145903974 0.875303616136575 0.88742362906566 0.891139058995563 0.88742362906566 0.875303616136575 0.804891787098888 0.850572919352248 0.8748327877438 0.887016150050328 0.890749965324109 0.887016150050328 0.8748327877438 0.803924646541311 0.849938420870972 0.874344852553506 0.886593896532246 0.890346778206742 0.886593896532246 0.874344852553506 0.802923062665784 0.849281407320154 0.873839632119557 0.886156715853014 0.889929352107764 0.886156715853014 0.873839632119557 Columns 15 through 21 0.860027724625518 0.819406816100522 0.73945998430288 0.54648424689384 0.00142161619427956 2.43084729262886 1.59531240321483 0.859945984205488 0.819272249504001 0.73915905309516 0.545456276528316 0.00108363894758305 2.41738586608871 1.59252628584049 0.859846344594196 0.819110963273262 0.738809165958537 0.544299753514466 0.000785407306238569 2.40332171769158 1.58962970028244 0.859728720994602 0.818922824829145 0.738410017273945 0.543013286063015 0.000535254369686337 2.3887038998402 1.58662794475596 0.859593022581209 0.818707691415155 0.737961275671475 0.541595360780282 0.000337844841847543 2.37358197730949 1.58352646523191 0.859439152511243 0.818465410062761 0.737462583754946 0.540044340118305 0.000193415505718568 2.35800565376575 1.58033083093547 0.859267007935557 0.818195817553739 0.736913557806601 0.538358459653941 9.74972609188272e-05 2.34202441913447 1.5770467099699 0.859076480009235 0.81789874037958 0.736313787471723 0.536535825197361 4.14288786769015e-05 2.32568722135227 1.57367984525057 0.858867453901971 0.817573994698036 0.735662835422997 0.534574409731243 1.38841345573212e-05 2.30904216529909 1.57023603092242 0.858639808808231 0.817221386286849 0.734960237004426 0.532472050182985 3.29753432268171e-06 2.29213624097042 1.56672108942093 0.858393417957269 0.816840710494778 0.734205499854637 0.530226444033575 4.62027633230311e-07 2.2750150822365 1.56314084932158 0.858128148623056 0.816431752189983 0.733398103509409 0.527835145768295 2.71055912222625e-08 2.25772275686375 1.55950112410687 0.857843862134208 0.815994285705922 0.732537498983284 0.525295563176333 3.22948550306881e-10 2.24030158785747 1.55580769196404 0.857540413884002 0.815528074784873 0.731623108330107 0.522604953508677 1.24680850971645e-13 2.22279200563449 1.55206627670895 0.857217653340589 0.815032872519222 0.730654324182401 0.519760419506382 2.55469946377954e-21 2.20523243005679 1.54828252991539 0.856875424057516 0.814508421290716 0.729630509269457 0.516758905314623 1.54930665875157e-54 2.18765918095627 1.54446201431187 0.856513563684711 0.813954452707842 0.728550995914078 0.513597192301849 3.41671232531819e+80 2.17010641545677 1.54061018849175 0.856131903980066 0.813370687541557 0.727415085507923 0.510271894808063 3.24686805562775e+22 2.15260609015113 1.53673239296693 0.855730270821781 0.812756835659587 0.726222047965439 0.506779455851866 8288261690176.8 2.13518794601396 1.5328338375805 0.855308484221667 0.812112595959559 0.724971121156388 0.503116142832518 955555268.4048 2.11787951381978 1.52891959027974 0.854866358339587 0.811437656301235 0.723661510317046 0.499278043271245 6888121.0910255 2.10070613778404 1.5249945672383 0.854403701499249 0.810731693438139 0.72229238744016 0.495261060645378 311446.363851474 2.08369101514479 1.52106352430478 0.853920316205595 0.809994372948917 0.720862890643832 0.491060910380125 37321.7583073078 2.0668552494467 1.51713104974444 0.853415999164014 0.809225349168762 0.719372123519537 0.486673116076024 7980.59155151307 2.05021791536973 1.51320155823206 0.852890541301651 0.808424265121299 0.717819154459559 0.482093006065898 2475.42753652677 2.03379613305406 1.50927928604599 0.852343727791084 0.807590752451314 0.716203015964205 0.477315710413793 988.899673155794 2.01760515000439 1.50536828740698 0.851775338076689 0.806724431358781 0.71452270392923 0.472336158490616 472.89459995784 2.0016584288035 1.50147243190023 0.851185145903974 0.805824910534651 0.712777176914006 0.467149077287515 258.146805183844 1.98596773902134 1.49759540291492 0.850572919352248 0.804891787098888 0.710965355391088 0.461748990659372 155.774472708584 1.97054325186758 1.49374069703263 0.849938420870972 0.803924646541311 0.709086120977907 0.456130219727928 101.592538192193 1.95539363629713 1.48991162429397 0.849281407320154 0.802923062665784 0.707138315651517 0.45028688471833 70.4522746341174 1.94052615543728 1.48611130927181 Columns 22 through 24 1.41626113275657 1.35214548670153 1.33490245205317 1.41475388434061 1.35100221610381 1.33384844899866 1.41319706805661 1.34982594024107 1.33276538753492 1.41159287976322 1.34861813661329 1.33165458272781 1.40994357864347 1.34738032439988 1.33051738633017 1.40825147912633 1.34611405957729 1.32935518257359 1.40651894277491 1.34482093000357 1.32816938392918 1.40474837019287 1.34350255049869 1.3269614268614 1.40294219299858 1.34216055794829 1.32573276759848 1.40110286591396 1.34079660645755 1.32448487794189 1.3992328590121 1.33941236258032 1.32321924113618 1.39733465016448 1.33800950064728 1.32193734781919 1.39541071772529 1.3365896982149 1.32064069207157 1.39346353348626 1.33515463165544 1.31933076758249 1.39149555593226 1.33370597190606 1.31800906394739 1.38950922382313 1.33224538039324 1.3166770631116 1.38750695012421 1.33077450514657 1.31533623597216 1.3854911163033 1.32929497711396 1.3139880391484 1.38346406700838 1.32780840668835 1.3126339119301 1.38142810513653 1.32631638045372 1.3112752734106 1.37938548730103 1.32482045815656 1.30991351981013 1.37733841969978 1.32332216990685 1.30855002199356 1.37528905438557 1.32182301361079 1.30718612318493 1.37323948593522 1.32032445263593 1.30582313687963 1.37119174851218 1.31882791370761 1.30446234495406 1.36914781331458 1.31733478503428 1.30310499597093 1.36710958639843 1.31584641465775 1.30175230367754 1.36507890686389 1.31436410902329 1.30040544569304 1.36305754539081 1.31288913176349 1.29906556238001 1.361047203108 1.31142270268859 1.29773375589449 1.35904951078013 1.30996599697534 1.29641108940824
the display is 0 in the matrix for all 31 days but when the days=16 there is an output. if days=17 the output starts to be 0

回答 (2 件)

VBBV
VBBV 2024 年 3 月 2 日
Cn = 0.7; % Clearance index
I0 = 1353; % Solar constant
latitude = -34.005133; % Latitude of the location
days =31; % Number of days in the month
hours = 24; % Number of hours in a day
% Initialize matrices to store results
dec_deg = zeros(days, 1); % Declination angles in degrees
DNI = zeros(days, hours); % Direct Normal Irradiation
DHI = zeros(days, hours); % Diffuse Horizontal Irradiance
GHI = zeros(days, hours); % Global Horizontal Irradiance
for n = 1:days
% Calculate declination angle for the day (in degrees)
dec_deg(n) = 23.45 * sind((360/365) * (n + 284));
% Convert declination angle from degrees to radians
dec_rad = deg2rad(dec_deg(n));
for time = 1:hours
% Calculate hour angle
h = (12 - time) * 15; % Hour angle in degrees
h_rad = deg2rad(h); % Hour angle in radians
% Calculate diffuse factor (Cs)
Cs = 0.095 + 0.04 * sin(deg2rad(360/365) * (n - 100));
% Calculate extraterrestrial solar irradiation (I)
I = I0 * (1 + 0.034 * cos(deg2rad(360 * n / 365.25)));
% Calculate atmospheric optical depth (k)
k = 0.174 + 0.035 * sin(deg2rad((360/365) * (n - 100)));
% Calculate solar altitude angle (alt)
Lat = deg2rad(latitude); % Latitude angle in radians
alt = asin(cos(Lat) * cos(dec_rad) * cos(h_rad) + (sin(Lat) * sin(dec_rad)));
alt_deg = rad2deg(alt); % Daily Solar Altitude Angle
% Calculate air mass (AM)
AM = 1 / sin(deg2rad(alt_deg)); % Air Mass
% Calculate Direct Normal Irradiation (DNI) for the current hour
DNI(n, time) = Cn * I * exp(-k * AM);
% Calculate Diffuse Horizontal Irradiance (DHI) for the current hour
DHI(n, time) = Cs * DNI(n, time);
% Calculate Global Horizontal Irradiance (GHI) for the current hour
GHI(n, time) = (DNI(n, time) + DHI(n, time)) / 1000;
end
end
% Display matrices
disp("Direct Normal Irradiation (DNI) for 31 days (24 hours each): ");
Direct Normal Irradiation (DNI) for 31 days (24 hours each):
vpa(DNI)
ans = 
disp("Diffuse Horizontal Irradiance (DHI) for 31 days (24 hours each): ");
Diffuse Horizontal Irradiance (DHI) for 31 days (24 hours each):
vpa(DHI)
ans = 
disp("Global Horizontal Irradiance (GHI) for 31 days (24 hours each): ");
Global Horizontal Irradiance (GHI) for 31 days (24 hours each):
vpa(GHI)
ans = 

Dyuman Joshi
Dyuman Joshi 2024 年 3 月 2 日
編集済み: Dyuman Joshi 2024 年 3 月 2 日
In the default display format (i.e. short), the numbers are displayed with 4 digits after the decimal.
Thus when the difference between the largest and the smallest number is quite big, the smaller numbers appear to be different than their values.
The values are still there, just too small to display in this format.
Let's see another example -
y = [1 23 456 1234567898765]
y = 1x4
1.0e+12 * 0.0000 0.0000 0.0000 1.2346
We know that the first 3 values are not 0. But when they are displayed (normalized according to the maximum value in the array) in the default format they appear as such.
Note that the value displayed is not the value stored.
> What can you do here?
You can change the display format, which I have done in your code (see the edit above). And as you can see, that the values are, in fact, not 0.
See format for more information.

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by