Example: MHKiT-MATLAB Wave Module

The following example runs an application of the MHKiT wave module to 1) generate a capture length matrix, 2) calculate MAEP, and 3) plot the scatter diagrams.

Load NDBC Data

We can use MHKiT to load data downloaded from https://www.ndbc.noaa.gov.
relative_file_name = 'data/wave/data.txt';
current_dir = fileparts(matlab.desktop.editor.getActiveFilename);
full_file_name = fullfile(current_dir, relative_file_name);
% height
ndbc_data = read_NDBC_file(full_file_name);
Warning: Calling STRUCT on an object prevents the object from hiding its implementation details and should thus be avoided. Use DISP or DISPLAY to see the visible public details of an object. See 'help struct' for more information.
disp(ndbc_data)
spectrum: [47×743 double] frequency: [47×1 double] time: [01-Jan-2018 00:40:00 01-Jan-2018 01:40:00 01-Jan-2018 02:40:00 01-Jan-2018 03:40:00 … ]

Compute Wave Metrics

We will now use MHKiT to compute the significant wave height, energy period, and energy flux.
% Compute the energy periods from the NDBC spectra data
Te = energy_period(ndbc_data);
disp(Te)
7.4587 7.6824 7.4983 7.6762 7.6695 7.4872 7.1609 7.0988 6.4084 6.6875 7.1311 7.9223 8.7329 10.5890 10.7495 11.5639 11.7032 12.7885 13.3933 13.5416 13.6975 13.4058 13.2554 14.0710 14.2076 13.5765 13.5911 13.3964 12.5708 12.8860 12.0561 11.9063 11.4389 11.8633 11.4712 11.1367 11.8808 11.0509 11.3901 11.2406 11.1560 11.1039 11.5390 10.9961 11.1551 11.1352 11.5514 11.7073 11.4691 11.6870 11.6822 11.0037 10.8002 11.0819 10.2768 11.1203 11.0551 11.9920 12.0477 12.0479 12.0368 12.5881 12.5354 13.1829 12.7431 12.6762 12.9947 12.8486 12.8892 12.9858 13.2110 13.2718 13.7024 13.0189 13.9925 13.7476 14.0039 14.1794 13.3190 13.5117 13.5267 12.9721 12.8560 12.9100 13.2160 12.2412 12.5926 12.3947 12.7596 12.7317 12.3590 12.3724 12.6146 11.9904 12.1634 12.3137 11.7800 11.7779 11.0509 10.6469 10.3666 9.9537 10.1165 9.4756 9.6439 9.2433 9.3079 9.2635 9.3129 9.4700 9.0210 8.8087 8.3257 8.0002 8.0392 7.9786 8.1206 8.3533 8.4946 8.4775 8.5920 8.5201 8.5312 8.9364 8.4345 8.8762 8.8705 8.7795 8.9736 8.5927 8.4116 8.5913 9.0705 8.6300 8.8096 8.9834 8.7747 8.9498 9.7479 10.0163 9.6683 9.7870 9.8794 10.3445 10.2322 10.5311 10.2943 10.3859 9.6956 9.5948 9.5831 9.2351 8.8655 9.1065 8.8338 8.7068 8.3943 8.2395 7.9697 7.4015 7.3304 6.8926 6.5768 7.0960 6.9503 7.7322 8.0245 8.1333 8.2798 8.6032 8.3794 8.3359 8.1413 8.1153 8.5248 8.4903 8.3500 8.6347 8.8721 8.6006 9.1193 9.2841 9.1109 8.9841 9.4384 9.8368 9.9946 9.8188 9.5230 9.6355 10.0682 10.1285 10.9016 10.9119 11.6178 11.6538 11.6443 11.7287 11.4225 10.9860 10.6865 11.0830 10.4920 10.5950 10.0258 9.5165 9.2913 8.7879 9.1370 8.7030 9.1986 9.8293 10.4437 10.4220 10.5583 10.1338 10.3477 9.6099 9.8454 9.6518 9.6576 9.6083 9.8903 9.5620 9.7073 10.2459 9.8208 10.1813 10.7860 11.2051 10.4997 10.1718 10.4792 10.0445 10.1969 9.8091 10.1113 9.0996 8.9366 8.4806 8.7080 8.4413 8.6442 9.2861 10.0928 10.5365 12.2502 12.3917 14.6814 13.7813 14.6484 12.6670 13.4769 10.9527 10.7440 9.8825 9.8507 9.0203 9.2295 10.0095 9.0649 9.3440 9.9396 9.4899 10.0669 10.5483 10.7475 10.2973 10.9479 10.0609 10.9283 11.6803 10.8986 11.5621 11.3216 11.0310 11.2943 10.7790 11.1152 10.8964 11.3743 10.4150 10.8328 11.6098 10.4282 11.0568 11.0963 10.6993 10.6091 10.4905 10.7892 10.9495 10.6091 10.1537 10.4253 10.2617 10.5955 10.2535 10.2804 10.2187 10.2592 10.4489 9.9576 10.2596 10.3297 11.0109 10.9485 10.5785 10.8503 11.3122 11.3979 10.9041 10.8663 10.8499 10.7462 11.9093 11.3235 11.9036 11.2670 10.4626 11.2251 10.4741 11.5700 11.1015 11.5630 11.5471 11.6773 11.2460 11.5230 11.9876 11.9342 12.4239 12.2645 13.3297 13.5462 12.8447 13.2558 14.7341 13.9966 13.5790 13.8883 13.1924 13.6952 13.3088 13.7035 13.4101 13.4046 13.7979 13.6026 13.1556 13.5696 13.3890 14.1740 13.9555 13.0981 12.9492 12.0522 11.9314 11.1963 10.8818 9.7844 9.7998 9.7488 9.9537 10.4116 10.4719 10.6263 10.6539 11.2000 11.4463 11.0588 11.4954 11.0325 11.3430 11.1108 11.2107 11.1472 11.2022 10.6727 11.0312 10.6329 10.9528 11.1013 11.0843 11.5453 11.5456 11.9380 12.1611 11.5921 11.7557 11.5419 11.0792 10.4957 10.4138 9.9285 9.8433 9.7195 9.3346 9.2688 9.2008 8.9019 9.0984 8.7751 9.4036 9.1745 9.7571 9.6200 9.3028 10.0438 10.2193 9.7753 10.0111 9.8614 11.0082 11.1374 13.2593 14.7071 15.9187 15.6053 15.4141 15.2556 15.5009 14.2855 14.0296 14.1887 13.9313 14.0420 14.4265 14.6840 14.3376 14.5785 13.3748 13.8405 13.1773 13.3679 13.0239 12.7860 12.6315 12.4391 12.0860 12.1366 12.0763 11.7334 12.5123 12.0178 12.0559 12.0162 12.2678 12.3176 12.2661 12.0164 11.6857 11.2850 11.2888 11.1805 10.8350 11.6088 11.4470 12.3649 11.4390 11.7176 11.7745 11.3721 11.5087 11.8762 11.8205 11.8907 11.5870 11.6881 11.9879 11.2793 11.7343 10.7543 11.5392 11.6172 10.5984 9.9949 10.1294 10.3332 9.4391 8.9503 8.6437 8.8069 8.6597 8.2914 8.5406 8.5918 8.4058 8.3942 8.5633 8.8703 8.9316 8.8931 9.1541 9.3553 10.0927 10.4958 10.9929 11.6249 11.6396 12.1595 11.4452 11.5892 10.9857 12.2263 12.0528 12.1067 11.5787 11.2316 11.6940 11.3726 11.2190 12.1616 11.6060 11.0849 11.1024 10.7352 11.0272 11.4502 11.4176 11.4619 11.3208 11.2978 11.1845 11.1688 10.9388 10.5697 10.5755 10.4225 10.2139 10.1083 10.3757 10.0294 10.4177 10.3698 9.7224 9.6763 9.2440 8.3011 8.8114 7.7243 7.4816 7.9739 7.8163 7.9005 7.9923 8.2196 8.4612 8.4067 8.5936 8.5487 8.6929 8.6683 8.7963 9.2602 9.2469 9.5187 9.6558 9.4157 9.7840 10.2024 9.8463 9.4667 9.9722 9.5229 10.0050 9.5498 8.8478 8.9882 9.2656 8.9110 9.1694 9.0145 8.8895 8.8205 8.7432 8.4610 8.6662 8.8386 8.6461 8.8719 8.4279 8.9780 8.2285 8.2252 7.9344 8.3447 8.5432 8.9808 9.1441 9.2321 9.6244 9.4760 9.6424 9.9524 10.4317 11.0913 11.1348 11.5575 11.7498 10.5879 11.3772 11.1150 11.1016 10.4365 10.0988 11.4995 10.7893 10.9920 11.1792 10.1690 9.9825 10.4816 10.2022 10.4722 10.1671 10.1153 9.8646 9.6358 9.3977 9.7045 9.7692 9.8618 9.1286 8.8781 8.2247 8.4410 8.4495 8.1291 8.0667 8.4065 8.5784 8.8692 9.2666 9.4071 9.3802 9.9998 9.7859 9.6355 9.4695 10.0118 9.5036 9.7920 9.6914 9.6073 9.3906 9.6507 9.1708 9.2998 9.3748 9.4978 9.4485 9.1727 9.1942 9.3357 9.7319 8.9871 9.9622 9.3888 9.8452 9.6260 9.1900 9.0100 9.4933 8.9395 9.3121 9.0677 8.7684 8.4802 8.3933 8.6319 8.4245 8.0898 8.5843 8.7058 8.6851 9.1779 9.3463 9.6994 9.5063 9.1794 9.1257 9.3531 9.4482 9.5668 8.8733 9.1741 9.4495 9.1522 9.2217 9.8963 9.4235 8.7623 8.6926 8.4383 8.5360 8.4692 8.3566 8.6964 8.3908 8.3627 8.5758 8.2837 8.6967 8.8499 8.7552 9.5270 9.3977 9.7389 10.1794 10.6852 10.5808 10.8269 11.5635 11.2191 11.1879 11.1134 11.0241 11.4430 11.2864 11.6048 11.3284 11.3650 11.4166 10.8819 11.5452 11.3061 10.7584 10.8899 11.1730 10.8418 10.6172 10.0516 10.4615 9.9019 10.3038 10.1432 10.3983 9.9676 10.2270 10.1005 10.6975 10.3857
% Compute the significant wave height from the NDBC spectra data
Hm0 = significant_wave_height(ndbc_data);
disp(Hm0)
0.9396 1.0014 0.9248 0.9625 0.9899 0.9077 0.8270 0.8229 0.7579 0.7362 0.6946 0.7164 0.7673 0.7702 0.8136 0.9248 0.9474 1.1393 1.3787 1.4231 1.5012 1.4957 1.6174 1.7519 2.0416 1.4796 1.6752 1.9991 1.5020 1.7231 1.6358 1.6565 1.6547 1.9734 1.8632 1.7776 2.2054 1.5430 1.9860 1.7727 1.8487 1.7260 2.0250 1.6200 1.5547 1.5036 1.5085 1.7589 1.6725 1.7937 1.9764 2.1123 2.0405 2.3157 2.0473 2.0640 1.9839 2.1994 2.4058 2.0717 2.1667 2.2680 2.2764 2.6078 2.4926 2.5988 2.9700 3.0042 2.6976 2.8703 2.4405 2.8508 3.1804 2.8305 3.1774 3.1907 3.2499 3.3094 2.6992 2.6945 2.7209 2.6319 2.5705 2.5706 3.1439 2.5672 2.7081 2.5694 2.5015 2.8454 2.5059 2.4551 2.4244 1.9381 2.0092 2.2060 1.9512 2.2166 2.3636 2.4617 2.5398 2.6243 2.8986 2.6605 2.5757 2.4522 2.2983 2.3380 2.4752 2.2600 2.4119 2.2190 2.2782 2.5502 2.9903 3.4619 3.8930 4.5413 4.7336 4.4827 4.3888 4.0312 3.2138 3.3339 3.2380 3.4653 3.5675 3.2808 3.0203 2.6880 2.7549 2.6141 2.7350 2.4608 2.6083 2.6847 2.6810 2.5798 2.6751 2.9914 2.7162 2.5226 2.5935 2.5383 2.3057 2.1988 2.2022 2.2768 1.9102 2.0003 2.0281 1.8659 2.1962 2.0889 2.0859 2.0293 1.8003 1.6520 1.5328 1.5074 1.5122 1.6275 1.6264 1.9649 2.0779 2.4913 2.7991 3.0571 2.8436 3.0979 3.1247 3.3397 2.9081 2.7212 2.7185 2.9199 2.7788 2.5731 2.7088 2.5546 2.5596 2.3500 2.6993 2.5380 2.7199 2.3787 2.5627 2.5704 2.5463 2.6473 2.5372 2.4765 2.5598 2.6173 2.7928 2.5803 2.6676 2.5439 2.6951 2.8680 2.6665 2.7737 2.7730 2.9129 2.7776 2.5616 2.9048 2.9659 2.8661 2.7903 2.7649 2.5693 2.9884 2.9566 2.7658 2.9898 3.0054 3.1109 3.2135 2.9767 3.1190 2.8828 2.9903 2.6923 2.4122 2.6745 2.4482 2.4559 2.5339 2.7322 2.4901 2.2294 2.3860 2.2318 2.3151 2.2981 2.3302 2.4514 2.2339 2.2911 2.3303 2.2812 2.1878 2.0047 1.9689 2.0710 1.9756 2.1016 2.7210 2.7903 3.3433 3.3201 3.5489 3.4822 4.0694 3.8468 4.1207 4.1879 4.4820 4.4670 3.8855 4.1794 4.3312 4.8175 4.8371 4.7019 5.0924 4.8648 5.0169 4.9169 4.9267 5.4801 5.0492 5.0093 5.0663 4.6756 4.4910 3.8949 4.2245 4.0641 3.9084 3.6448 3.5329 3.6007 3.5437 3.1564 3.5733 3.2202 3.2082 3.1083 2.9923 3.0558 2.7733 2.6398 2.5025 2.4562 2.5147 2.3144 2.4585 2.2641 2.1463 2.2532 2.0081 2.0728 1.8378 2.0693 1.9375 1.8812 2.1027 2.2455 2.0965 2.2350 2.0580 2.2509 2.2238 2.3723 2.3513 2.4213 2.1279 1.8994 2.4605 2.0867 2.4126 2.0783 2.5421 2.6329 2.3426 2.3430 2.4465 2.4162 2.4462 2.4047 2.3089 2.5379 2.5339 2.5897 2.6852 2.8831 2.7263 2.8110 3.0042 3.1829 3.1658 3.6583 3.5881 3.7006 3.7525 3.8500 4.0369 3.7557 3.8103 3.5052 4.1801 3.6509 3.8666 3.4717 2.9257 3.0819 3.0608 3.3843 3.4182 3.9974 4.5028 4.1192 3.9758 3.8940 4.0771 4.0294 3.5758 3.9731 3.6424 3.6749 3.6549 3.5956 3.6391 3.5700 3.5208 3.4967 3.3356 3.3438 3.4564 3.3718 3.5518 3.0569 3.1419 3.2347 3.2058 3.3152 3.1050 3.2335 3.0696 3.0873 2.7897 3.2548 3.2245 3.2142 3.2059 3.4102 3.4267 3.6192 3.8281 3.9842 4.3129 4.9459 4.9671 5.8257 5.9464 5.7593 5.4849 6.2759 5.4924 5.2934 5.1958 5.4249 5.5946 7.4323 7.8536 9.8264 10.3109 9.3151 10.3829 8.6308 7.4778 7.3413 8.1502 7.7282 7.9501 7.6824 8.0233 7.4499 8.4346 6.9643 7.4362 6.4677 6.9778 6.8344 6.3455 5.8620 5.9538 5.7432 5.1847 5.3761 4.9766 5.1546 5.1667 5.3276 4.8471 5.2032 5.4275 5.4077 5.6415 5.0051 5.2332 4.5784 4.5706 4.5512 4.6229 4.6695 5.0483 4.3658 4.7439 5.2097 4.5592 5.0945 5.2801 5.9514 5.4574 5.1005 5.4169 4.9158 4.6811 4.9142 3.9432 4.4634 4.5279 3.7743 3.7201 3.8237 4.1733 3.8092 3.8878 3.9458 4.2111 4.0498 4.0890 4.4814 4.8329 4.2840 4.9765 4.7806 5.2517 5.3383 5.6953 5.4535 6.3394 7.4932 6.5225 6.6410 7.2449 6.0693 5.5664 5.5016 4.9012 4.6578 4.3335 4.4643 4.5652 4.7091 4.3044 4.8600 4.6896 4.8160 6.0625 5.2117 4.8620 4.5241 4.1310 4.1746 4.2343 3.9332 3.7558 3.6128 3.7086 3.7051 3.7889 3.6080 3.4807 3.3302 3.5199 3.4875 3.2303 3.4589 3.1039 3.3870 2.9739 2.7950 2.6539 2.3795 2.4028 2.8228 3.2036 3.1666 4.0506 4.1597 4.4871 4.2666 4.5867 5.2511 4.6659 4.5198 4.4966 4.5334 4.7037 5.2210 5.5747 5.5078 5.6325 4.8293 4.6752 4.9780 4.6586 4.2885 3.9486 4.1384 3.9262 4.2906 3.5779 3.4442 3.3079 2.9387 2.7270 2.7255 2.7298 2.7174 2.7347 2.6089 2.6733 3.1234 3.0954 2.9762 3.0950 3.0625 3.3269 3.3345 3.9180 3.7314 4.3813 4.0431 3.6955 3.3673 3.5743 3.7713 3.4927 3.5979 3.9070 4.2234 4.1276 4.6184 4.7397 4.7786 3.7264 3.9168 3.8015 3.9833 3.5011 3.4225 4.0378 3.8343 4.1690 4.1229 4.0223 4.0781 4.5158 4.4536 4.6191 4.3443 4.2877 3.8891 3.7536 3.6292 3.6666 3.7042 3.6009 3.5044 3.6625 3.9087 4.2019 4.3259 4.5012 4.4095 4.8364 5.2872 6.1236 5.5994 6.3178 5.3173 5.6268 4.6348 4.4863 4.3809 4.2442 3.9520 3.9148 3.5221 3.9327 3.5825 3.7505 3.6447 3.6027 3.6771 3.6037 3.7379 3.2804 3.2719 3.1892 3.3616 2.8222 3.2830 2.9674 2.9647 2.9141 2.7631 2.8090 2.8896 2.5728 2.8905 2.6531 2.5863 2.4605 2.2238 2.0139 2.1603 1.7669 1.9067 1.9464 2.0225 2.1516 2.2774 2.7695 2.6047 2.7559 3.0416 3.2553 3.3872 3.7324 3.1126 3.2973 3.1669 3.2076 2.9615 3.1345 3.0733 3.0455 3.5248 3.2874 3.2962 3.1138 3.0428 3.1989 2.9414 3.0286 2.9868 2.6979 2.7507 2.7380 2.7040 2.6525 2.7584 2.9698 2.9744 3.0556 3.2608 3.6160 3.8084 3.8799 3.8005 3.9360 3.7440 4.3232 4.2754 3.6573 3.8704 3.8077 3.7765 3.3792 3.7723 3.5237 3.4218 3.5606 3.4539 3.5653 3.3758 2.8173 3.5818 2.9713 3.1743 3.0333 3.3074 2.6508 3.0867 2.6504 2.9414 2.8959
% Set water depth to 60 m
h = 60;
 
% Compute the energy flux from the NDBC spectra data and water depth
J = energy_flux(ndbc_data,h);
disp(J)
1.0e+05 * 0.0335 0.0392 0.0328 0.0366 0.0387 0.0318 0.0255 0.0252 0.0192 0.0191 0.0183 0.0220 0.0284 0.0354 0.0402 0.0564 0.0599 0.0957 0.1471 0.1588 0.1790 0.1733 0.2000 0.2511 0.3445 0.1713 0.2199 0.3084 0.1613 0.2191 0.1822 0.1840 0.1752 0.2603 0.2225 0.1955 0.3243 0.1456 0.2506 0.1972 0.2115 0.1839 0.2647 0.1603 0.1501 0.1399 0.1467 0.2020 0.1779 0.2096 0.2539 0.2690 0.2457 0.3275 0.2330 0.2622 0.2400 0.3258 0.3916 0.2903 0.3161 0.3662 0.3675 0.5114 0.4494 0.4858 0.6530 0.6572 0.5328 0.6077 0.4481 0.6162 0.7964 0.5937 0.8101 0.8034 0.8505 0.8926 0.5560 0.5629 0.5749 0.5132 0.4845 0.4862 0.7499 0.4569 0.5243 0.4628 0.4563 0.5884 0.4397 0.4227 0.4232 0.2540 0.2778 0.3397 0.2529 0.3252 0.3438 0.3560 0.3670 0.3716 0.4613 0.3595 0.3449 0.2969 0.2641 0.2713 0.3047 0.2602 0.2771 0.2299 0.2277 0.2704 0.3744 0.4904 0.6292 0.8787 0.9725 0.8726 0.8486 0.7131 0.4557 0.5197 0.4614 0.5587 0.5905 0.4915 0.4291 0.3227 0.3301 0.3052 0.3548 0.2728 0.3141 0.3399 0.3293 0.3148 0.3766 0.4871 0.3833 0.3357 0.3590 0.3634 0.2957 0.2778 0.2710 0.2907 0.1881 0.2025 0.2076 0.1683 0.2204 0.2078 0.1995 0.1864 0.1413 0.1165 0.0974 0.0872 0.0874 0.0938 0.0889 0.1404 0.1530 0.2461 0.3220 0.3891 0.3439 0.4252 0.4204 0.4748 0.3512 0.3079 0.3266 0.3742 0.3317 0.2979 0.3393 0.2916 0.3139 0.2719 0.3487 0.3027 0.3685 0.2997 0.3534 0.3486 0.3298 0.3601 0.3489 0.3357 0.3935 0.4107 0.5044 0.4334 0.4609 0.4222 0.4594 0.4957 0.4143 0.4693 0.4392 0.4909 0.4168 0.3359 0.4198 0.4105 0.4016 0.3589 0.3774 0.3524 0.5106 0.4992 0.4450 0.4919 0.5094 0.4962 0.5458 0.4592 0.5031 0.4284 0.4777 0.3720 0.3051 0.3987 0.3175 0.3343 0.3817 0.4648 0.3563 0.2750 0.3278 0.2732 0.2990 0.2820 0.3014 0.2942 0.2405 0.2370 0.2527 0.2325 0.2180 0.1980 0.2094 0.2437 0.2622 0.2989 0.6041 0.5926 0.9157 0.7717 0.9457 0.7256 0.9728 0.7818 0.8848 0.8273 0.9743 1.0636 0.7206 0.8557 0.9948 1.1545 1.2577 1.2599 1.5104 1.3093 1.5059 1.3076 1.4568 1.9576 1.5282 1.6126 1.6139 1.3291 1.2654 0.8970 1.0964 0.9861 0.9653 0.7505 0.7420 0.8391 0.7122 0.6080 0.7819 0.6093 0.6007 0.5529 0.5328 0.5651 0.4475 0.3844 0.3545 0.3344 0.3647 0.2967 0.3360 0.2836 0.2571 0.2899 0.2166 0.2395 0.1902 0.2606 0.2262 0.2035 0.2621 0.3141 0.2761 0.2970 0.2517 0.2987 0.2885 0.3750 0.3460 0.3914 0.2827 0.2067 0.3768 0.2490 0.3757 0.2641 0.4145 0.4424 0.3495 0.3347 0.3771 0.3875 0.3951 0.3918 0.3595 0.4740 0.4819 0.4799 0.5318 0.6824 0.5801 0.5998 0.6983 0.7496 0.7687 1.0052 0.9950 1.0385 1.0632 1.1529 1.2590 1.0499 1.1156 0.9348 1.4158 1.0591 1.1154 0.8864 0.5774 0.6326 0.5800 0.6867 0.6178 0.8376 1.0542 0.9036 0.8958 0.8653 0.9651 0.9445 0.7898 1.0029 0.8080 0.8616 0.8118 0.8116 0.8125 0.7918 0.7609 0.7568 0.6494 0.6815 0.6934 0.6855 0.7737 0.5716 0.6355 0.6726 0.6878 0.7503 0.6213 0.6848 0.6041 0.5819 0.4474 0.6030 0.5587 0.5508 0.5412 0.5796 0.5808 0.6394 0.6857 0.7668 0.8517 1.2214 1.1930 1.7608 1.8021 1.6161 1.6255 2.1652 1.5712 1.5072 1.4286 1.7837 1.9120 4.1258 5.1349 8.6922 9.4338 7.5885 9.3482 6.5341 4.4961 4.2641 5.3369 4.7119 5.0488 4.8442 5.3892 4.5418 5.9425 3.6872 4.3529 3.1259 3.7120 3.4590 2.9165 2.4449 2.4861 2.2376 1.8352 1.9625 1.6305 1.8884 1.8054 1.9259 1.5893 1.8764 2.0516 2.0170 2.1485 1.6377 1.7096 1.3138 1.2967 1.2348 1.3876 1.3912 1.7798 1.2148 1.4772 1.7908 1.3130 1.6661 1.8585 2.3412 1.9914 1.6782 1.9151 1.6258 1.3688 1.5849 0.9169 1.2844 1.3325 0.8277 0.7515 0.8088 0.9877 0.7347 0.7174 0.7065 0.8229 0.7442 0.7168 0.8897 1.0380 0.7942 1.0650 1.0114 1.2683 1.3205 1.4888 1.4233 1.9604 3.0153 2.4025 2.6400 3.3745 2.3764 2.1077 1.9112 1.5404 1.3079 1.2843 1.3430 1.4136 1.4243 1.1491 1.5376 1.3875 1.4327 2.5142 1.7524 1.4407 1.2561 1.0015 1.0564 1.1389 0.9817 0.8998 0.8183 0.8601 0.8467 0.8833 0.7815 0.6960 0.6401 0.7031 0.6724 0.5694 0.6756 0.5226 0.6491 0.4994 0.4071 0.3675 0.2809 0.2529 0.3742 0.4117 0.3794 0.6664 0.6806 0.7999 0.7360 0.8727 1.1858 0.9335 0.9033 0.8894 0.9200 0.9879 1.2369 1.5025 1.4671 1.5921 1.1893 1.0791 1.2774 1.1820 0.9614 0.7810 0.9069 0.7694 0.9799 0.6449 0.5427 0.5143 0.4227 0.3485 0.3588 0.3552 0.3459 0.3474 0.3133 0.3156 0.4399 0.4451 0.4003 0.4454 0.4113 0.5236 0.4735 0.6547 0.5686 0.8246 0.7205 0.6432 0.5445 0.6202 0.7259 0.6139 0.6670 0.8120 1.0132 1.0446 1.3115 1.4478 1.5026 0.8072 0.9735 0.8926 0.9751 0.6993 0.6425 1.0480 0.8726 1.0568 1.0555 0.8913 0.8957 1.1661 1.0999 1.2169 1.0405 1.0096 0.8044 0.7291 0.6629 0.7048 0.7267 0.6927 0.6008 0.6352 0.6502 0.7779 0.8163 0.8407 0.7967 1.0066 1.2283 1.7087 1.5237 1.9766 1.3972 1.6939 1.1268 1.0309 0.9612 0.9673 0.7827 0.7992 0.6395 0.7858 0.6335 0.7156 0.6357 0.6320 0.6654 0.6512 0.6960 0.5214 0.5189 0.5009 0.5875 0.3783 0.5798 0.4407 0.4649 0.4373 0.3724 0.3739 0.4224 0.3103 0.4109 0.3348 0.3050 0.2661 0.2151 0.1834 0.2044 0.1306 0.1626 0.1712 0.1844 0.2228 0.2546 0.3924 0.3408 0.3641 0.4398 0.5216 0.5720 0.7047 0.4485 0.5253 0.5074 0.5004 0.4332 0.5284 0.4773 0.4303 0.5675 0.4765 0.4818 0.4263 0.3999 0.4634 0.3752 0.3963 0.3986 0.3136 0.3433 0.3483 0.3360 0.3574 0.3804 0.4615 0.4882 0.5471 0.6150 0.7758 0.9361 0.9365 0.8929 0.9501 0.8499 1.1873 1.1439 0.8685 0.9412 0.9151 0.9046 0.6835 0.9160 0.7794 0.6902 0.7552 0.7376 0.7574 0.6568 0.4290 0.7284 0.4700 0.5636 0.5038 0.6149 0.3760 0.5253 0.3815 0.5050 0.4707

Generate Random Power Data

For demonstration purposes, this example uses synthetic power data generated from statistical distributions. In a real application, the user would provide power values from a WEC.
% generating 1,000,000 random power values
Power = randi([40,200], 743,1);
disp(Power)
171 185 60 187 141 55 84 128 194 195 65 196 194 118 168 62 107 187 167 194 145 45 176 190 149 161 159 103 145 67 153 45 84 47 55 172 151 91 192 45 110 101 163 168 70 118 111 144 154 161 84 149 145 66 59 120 194 94 134 76 160 81 121 152 183 194 128 62 64 81 175 80 171 79 189 96 71 80 139 116 96 173 134 128 187 86 161 161 101 131 52 48 125 165 190 60 131 115 41 94 66 167 90 125 66 136 82 145 150 160 112 53 76 187 64 172 126 200 52 111 57 194 40 164 171 179 53 104 81 168 109 186 69 82 63 61 179 133 128 63 177 140 96 122 104 52 78 59 69 78 107 47 185 192 119 118 94 184 99 57 165 102 78 105 55 61 191 193 132 49 77 96 172 42 46 67 144 157 144 112 128 87 159 70 150 69 99 140 165 53 189 164 118 110 111 89 121 122 171 167 143 100 170 125 96 191 181 128 140 134 73 88 115 77 175 71 76 67 76 110 90 188 109 69 185 197 110 57 81 105 135 82 137 154 75 58 87 91 108 121 53 82 168 44 189 157 118 133 78 113 195 128 123 77 118 140 149 103 99 199 46 182 187 168 55 82 93 149 61 156 57 145 119 165 155 185 183 93 152 71 44 159 120 117 185 138 139 178 169 132 69 78 182 44 118 67 197 154 120 115 49 149 46 51 123 55 171 171 156 64 146 123 196 144 168 113 109 172 53 61 67 102 173 169 49 104 124 107 145 141 87 109 42 198 66 57 99 71 118 94 193 188 48 158 83 108 128 191 107 198 88 152 147 126 152 147 68 60 200 67 45 130 181 147 70 99 114 198 65 177 143 100 70 108 117 59 134 76 101 133 80 86 139 82 172 198 157 95 134 57 185 181 171 81 135 43 108 90 65 68 108 55 136 115 152 152 142 45 51 91 125 145 105 172 155 195 125 92 57 138 165 108 54 82 64 85 110 124 113 180 123 191 142 194 78 148 86 148 151 50 81 76 147 175 95 165 148 41 136 102 187 40 114 108 114 163 91 166 115 45 68 156 116 64 94 137 70 158 79 187 83 163 70 86 54 132 150 128 108 143 144 149 142 192 73 154 78 59 137 112 113 146 164 96 146 107 175 174 81 138 133 127 180 82 91 59 191 143 117 142 127 144 127 156 124 199 75 57 57 50 105 112 98 162 141 164 190 196 70 62 152 55 124 125 178 118 103 148 159 123 95 64 134 82 47 161 79 111 150 97 158 103 150 153 111 43 93 108 83 71 172 109 182 102 163 103 170 161 100 74 167 192 92 148 110 174 163 66 178 199 122 182 134 64 72 105 160 172 167 91 125 54 57 61 149 119 70 119 63 48 176 130 189 152 133 171 181 199 40 179 138 199 124 117 169 76 120 185 132 176 158 134 79 147 53 140 146 157 183 198 163 133 189 133 42 59 178 117 176 73 128 141 45 138 98 47 118 70 59 73 63 70 46 142 85 126 151 120 126 111 59 118 177 180 83 73 130 143 107 73 192 53 57 62 66 139 132 48 189 157 158 50 178 190 198 178 166 122 68 104 61 44 191 88 87 93 115 144 44 175 130 177 96 111 48 68 146 93 184 59 199 126 153 200 86 106 114 162 171 56 68 97 49 124 94 68 73 185 148 115 186 56 160 158 130 69 136 88 61 74 184 51 79

Capture Length Matrices

The following operations create capture length matrices, as specified by the IEC/TS 62600-100. But first, we need to calculate capture length and define bin centers. The mean capture length matrix is printed below. Keep in mind that this data has been artificially generated, so it may not be representative of what a real-world scatter diagram would look like.
% calculating capture length with power and wave flux in vectors
L = capture_length(Power,J)
L = 743×1
0.0510 0.0472 0.0183 0.0510 0.0365 0.0173 0.0329 0.0507 0.1009 0.1023
 
% Need to set our Hm0 and Te bins for the capture length matrix
Hm0_bins = -0.5:0.5:max(fix(Hm0))+0.5; % Input is min, max, and n indecies for vector
Hm0_bins = Hm0_bins+0.25 ;
Te_bins = 0:1:max(fix(Te));
Te_bins = Te_bins+0.5;
 
% Calculate the necessary capture length matrices for each statistic based
% on IEC/TS 62600-100
clmat.mean = capture_length_matrix(Hm0,Te,L,"mean",Hm0_bins,Te_bins);
clmat.std = capture_length_matrix(Hm0,Te,L,"std",Hm0_bins,Te_bins);
clmat.count = capture_length_matrix(Hm0,Te,L,"count",Hm0_bins,Te_bins);
clmat.min = capture_length_matrix(Hm0,Te,L,"min",Hm0_bins,Te_bins);
clmat.max = capture_length_matrix(Hm0,Te,L,"max",Hm0_bins,Te_bins);
 
% Calculate the frequency matrix for convenience
clmat.freq = capture_length_matrix(Hm0,Te,L,"frequency",Hm0_bins,Te_bins);
Let's see what the data in the mean matrix looks like. Keep in mind that this data has been artificially generated, so it may not be representative of what a real-world scatter diagram would look like.
disp(clmat.mean.values)
Columns 1 through 14 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.1016 0.0425 0.0683 NaN 0.0376 0.0144 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0472 NaN NaN NaN NaN 0.0195 0.0089 NaN NaN NaN NaN NaN NaN 0.0098 0.0108 0.0069 0.0032 0.0075 0.0057 0.0062 0.0069 NaN NaN NaN NaN NaN NaN 0.0036 0.0025 0.0051 0.0042 0.0039 0.0035 0.0032 0.0039 NaN NaN NaN NaN NaN NaN NaN NaN 0.0038 0.0033 0.0029 0.0024 0.0022 0.0021 NaN NaN NaN NaN NaN NaN NaN 0.0025 0.0027 0.0018 0.0019 0.0021 0.0014 0.0020 NaN NaN NaN NaN NaN NaN NaN 0.0018 0.0017 0.0016 0.0017 0.0013 NaN 0.0013 NaN NaN NaN NaN NaN NaN NaN 0.0015 0.0018 0.0015 0.0012 0.0010 0.0006 0.0008 NaN NaN NaN NaN NaN NaN NaN NaN 0.0013 0.0011 0.0010 0.0009 0.0011 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0011 0.0007 0.0006 0.0007 0.0006 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0011 0.0007 NaN 0.0007 0.0006 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0011 0.0005 0.0004 0.0006 0.0004 0.0006 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0007 NaN NaN 0.0004 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0004 0.0002 NaN 0.0004 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0002 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Columns 15 through 16 NaN NaN NaN NaN NaN NaN NaN NaN 0.0076 NaN 0.0043 NaN 0.0012 NaN 0.0013 NaN NaN NaN 0.0010 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.0002 NaN 0.0002 NaN 0.0002 NaN NaN 0.0002 NaN 0.0002 NaN 0.0001 NaN 0.0001 NaN NaN

Power Matrices

As specified in IEC/TS 62600-100, the power matrix is generated from the capture length matrix and wave energy flux matrix, as shown below
% Create wave energy flux matrix using mean
jmat = wave_energy_flux_matrix(Hm0,Te,J,"mean",Hm0_bins,Te_bins);
 
% Create power matrix using mean
avg_power_mat = power_matrix(clmat.mean, jmat);
 
% Create power matrix using standard deviation
std_power_mat = power_matrix(clmat.std, jmat);
The capture_length_matrix function can also be used as an arbitrary scatter plot generator. To do this, simply pass a different array in the place of capture length (L). For example, while not specified by the IEC standards, if the user doesn't have the omnidirectional wave flux, the average power matrix could hypothetically be generated in the following manner:
avgpowmat_not_standard = capture_length_matrix(Hm0,Te,Power,'mean',Hm0_bins,Te_bins);

MAEP

There are two ways to calculate mean annual energy production (MAEP). One is from capture length and wave energy flux matrices, the other is from time series data, as shown below.
% Calculate maep from timeseries
maep_timeseries = mean_annual_energy_production_timeseries(L,J)
maep_timeseries = 1.0474e+06
% Calculate maep from matrix
maep_matrix = mean_annual_energy_production_matrix(clmat.mean, jmat , clmat.freq)
maep_matrix = 1.0589e+06

Graphics

The graphics function plot_matrix can be used to visualize results. It is important to note that the plotting function assumes the step size between bins to be linear.
% Plot the capture length matrix
p1 = plot_matrix(clmat.mean,"Capture Length");