Undefined function or method 'mrdivide'

4 views (last 30 days)
I wrote the following code which is automatically generated by the ntstool of MATLAB for the training of a NARX neural network.
function y = supply_chain(x)
% Solve an Autoregression Problem with External Input with a NARX Neural Network
% Script generated by Neural Time Series app
% Created 03-Jan-2021 16:37:16
%
% This script assumes these variables are defined:
%
% a - input time series.
% b - feedback time series.
a = [4972 129 0;4902 129 70;4843 129 59;4750 129 93;4654 129 96;4509 129 145;4329 129 179;4104 129 321;4459 109 125;5043 109 88;5239 109 188;5118 109 121;4984 109 134;4904 109 80;4822 109 82;4728 119 94;4464 119 159;4265 119 199;4161 119 104;4091 119 70;3964 109 127;3868 109 96;3793 109 75;3595 109 198;3427 109 168;3302 109 125;3216 109 86;2994 99 222;2723 99 272;2514 99 209;2145 99 369;1928 99 217;1831 99 97;1714 99 117;1998 129 100;2126 129 64;2091 129 35;2037 129 54;1982 129 55;7228 129 8;7185 109 43;7078 109 107;6962 109 116;6875 109 87;6809 109 66;6765 109 44;6731 109 33;6718 109 13;6665 109 53;6593 109 72;6543 109 50;6528 109 15;6516 109 12;6445 109 71;6412 109 37;6329 109 83;6237 109 94;6178 109 59;6129 109 49;6012 109 65;5957 109 55;5880 109 77;5755 109 122;5672 109 83;5597 109 75;5549 109 48;5504 129 45;4659 129 78;4537 129 122;4274 129 116;4228 129 48;4199 129 29;4107 129 91;4048 129 59;3980 129 68;3843 128 137;3787 129 56;3774 129 13;3729 129 45;3704 129 25;3679 129 25;3505 119 174;3367 109 138;3303 109 64;3226 109 77;3164 109 62;3045 109 119;2956 109 89;2823 109 133;2643 109 180;2522 109 121;2450 109 72;2359 109 91;2306 109 53;2259 109 47;2217 109 42;2092 109 124;1995 109 97;1875 109 119;1841 129 34;1823 129 18;1799 129 24;1742 129 57;1681 129 61;1651 129 30;1554 129 96;1525 129 0;1488 129 37;1458 129 30;1420 129 38;1332 129 88;1268 129 64;1255 129 13;1255 129 20;1457 129 31;1263 129 129;1169 129 94;1904 129 129;1778 129 126;1708 129 70;1708 129 48;2044 129 123;1930 129 87;1961 129 65;1859 129 102;1781 129 78;1828 129 49;1800 129 0;1687 109 68;1969 109 102;1977 109 88;1807 109 170;1655 109 152;1661 109 90;1751 109 101;1680 143 71;2016 149 48;1976 149 40;1883 149 93;1838 149 45;1876 149 58;1919 149 53;3317 149 42;3841 149 52;3811 199 29;3720 199 91;3645 199 75;3570 199 75;3391 119 179;3140 119 252;2938 119 202;2777 119 161;2446 119 331;2175 119 271;1949 119 146;1946 119 2;2136 119 2;2136 0 0;2328 149 0;2328 149 0;2315 149 13;2285 149 30;2251 149 34;2243 149 8;2176 129 67;2135 129 41;2046 129 89;1997 129 49;2031 129 62;2046 129 81;2004 129 42;2037 129 63;1930 118 107;1847 119 83;1745 119 102;1779 129 62;1750 129 29;1687 129 63;1590 129 97;1454 129 136;1119 129 335;820 129 299;814 129 5;812 129 2;803 129 9;794 129 9;794 129 0;794 129 0;794 129 0;794 129 0;794 0 0;794 0 0;794 0 0;794 0 0;794 149 0;794 149 0;794 149 0;792 149 2;792 149 0;888 149 0;873 149 15;864 149 9;851 149 13;1220 122 15;1207 298 26;1191 155 16;1140 155 51;1093 155 47;1037 155 56;992 155 45;952 155 40;935 155 17;832 129 103;760 129 72;704 129 56;704 129 0;703 129 1;703 129 0;703 129 0;703 129 0;703 129 0;703 155 0;703 155 0;703 155 0;2143 155 0;2143 155 0;2075 155 68;1908 119 169;1695 119 213;1356 119 338;1227 119 129;1271 119 13;1186 119 85;1186 0 0;1186 129 0;1186 129 0;1186 129 0;1474 129 0;1474 129 0;1474 129 0;1474 129 0;2146 129 0;2146 129 0;2146 129 0;2082 129 64;1928 129 154;1785 129 143;1689 129 96;1549 129 140;1484 129 67;1481 129 3;1410 129 71;1352 129 58;1962 129 62;1996 129 62;2126 129 62;2532 129 168;2433 129 99;2394 129 39;2285 129 64;2168 129 117;2064 129 104;1956 129 108;1014 129 234;917 129 97;832 129 85;1896 129 88;1801 129 190;1637 129 163;1835 129 90;1730 129 105;1683 129 47;2097 129 66;2109 129 84;2028 129 80;1934 129 97;2254 129 64;2126 129 128;2041 129 85;2087 129 50;1996 129 91;1903 129 93;1852 129 50;2246 129 85;2117 129 129;1998 129 119;2049 129 45;2067 129 78;1977 129 90;1899 129 78;1837 129 62;1740 129 97;1629 129 111;1574 129 55;1510 129 60;1449 129 61;1368 149 81;1237 149 131;1077 149 160;946 149 131;903 149 43;869 149 34;836 149 33;799 149 37;717 149 82;175 149 542;0 149 239;0 149 51;80 149 51;34 149 41;33 149 1;33 149 0;32 149 1;32 149 0;32 149 0;25 149 7;24 149 1;20 129 4;19 129 1;18 129 1;16 129 2;16 129 0;16 129 0;16 129 0;16 129 0;16 129 0;16 129 0;16 129 0;16 129 0;16 129 0;16 129 0;16 129 0;16 149 0;16 149 0;16 149 0;16 149 0;16 149 0;16 149 0;16 149 0;16 149 0;16 149 0;16 149 0;688 149 0;735 149 49;578 129 157;385 129 193;291 129 94;156 129 135;38 129 118;116 129 18;116 129 0;102 129 14;102 129 0;82 129 20;328 129 42;283 129 45;612 129 55;553 129 59;542 129 11;542 129 0;561 129 77;2229 129 60;2228 129 1;2351 129 69;2253 129 98;2134 129 119;2137 129 93;2045 129 92;1933 129 112;1837 129 96;1744 129 93;1679 129 65;1581 129 100;1530 149 51;1475 149 55;1403 149 71;1346 149 57;1312 149 34;1265 149 47;1177 129 88;1126 129 51;1076 129 49;966 129 110;936 129 30;877 129 59;780 129 97;625 129 155;500 129 125;496 129 100;285 129 211;197 129 88;467 129 114;570 129 89;548 129 118;1136 129 84;1299 129 125;1211 104 184;1104 129 107;1033 129 70;1063 129 66;974 129 89;1116 284 50;1096 289 20;1019 289 77;986 289 33;1035 289 47;1000 289 35;1228 289 60;1197 289 31;1162 289 35;1082 287 80;1039 289 42;1016 289 23;997 289 19;1075 289 18;1134 289 37;1084 289 50;957 289 127;834 289 123;789 289 44;767 289 22;736 289 31;714 289 22;674 289 40;612 289 62;553 289 59;525 289 28;458 149 68;385 149 73;298 149 87;1878 129 175;1575 129 300;1379 129 196;1256 129 123;1088 129 168;1263 129 209;1075 129 188;856 129 219;475 129 381;317 129 158;304 149 12;296 129 8;286 129 10;774 129 88;770 129 196;660 129 206;577 129 83;673 149 0;673 149 0;646 149 27;1002 149 27;1044 149 54;908 149 136;853 149 55;831 149 22;801 149 30;771 149 30;930 149 30;1078 149 44;1423 149 39;1366 149 57;1336 149 30;1385 149 47;1311 149 74;1196 139 114;1156 139 40;1094 139 62;1032 139 62;897 139 135;722 139 175;736 139 82;674 14 62;586 14 88;434 14 152;370 14 64;591 14 67;806 139 73;676 139 130;657 139 115;397 139 260;169 139 228;49 139 120;18 139 31;18 139 0;15 139 3;15 139 0;15 139 0;15 0 0;15 149 0;14 149 1;14 149 0;13 149 1;12 149 1;10 149 1;10 149 0;10 149 0;10 149 0;9 149 1;9 149 0;9 149 0;9 149 0;9 149 0;9 149 0;9 139 0;9 139 0;9 139 0;9 139 0;9 139 0;9 139 0;9 139 0;105 139 0;105 139 0;105 139 0;105 139 0;1377 139 168;1176 12 201;1029 119 147;910 119 119;788 119 122;639 119 149;720 119 111;721 119 95;675 119 237;565 119 110;653 119 104;592 119 61;1127 129 40;1301 129 114;1172 129 129;1061 129 111;915 129 146;858 149 57;839 149 19;1291 149 27;1229 149 62;1902 149 95;1719 139 183;1624 139 94;1606 139 116;1543 139 63;1396 139 147;1295 139 101;1047 129 248;905 129 142;719 129 186;898 129 109;957 129 228;1083 129 66;901 129 182;996 129 1;1124 129 64;1006 129 118;950 129 55;907 127 43;812 128 95;758 128 54;673 128 85;869 127 92;808 128 61;697 127 111;1170 128 7;1262 128 4;1292 127 66;1197 128 95;1103 127 190;1043 128 60;1097 127 42;1306 127 79;1581 127 109;1416 128 165;1317 127 99;1084 148 233;1067 148 16;1065 146 2;1060 147 5;1038 148 22;1030 149 8;321 148 65;451 148 157;386 148 65;296 148 90;1157 118 3;1152 118 5;2015 119 1;2046 118 65;1811 117 235;1735 118 76;1733 119 2;1632 118 101;1470 117 162;1446 117 25;1442 116 4;1441 119 1;1366 117 75;1334 118 32;1258 118 76;1252 117 6;1285 118 65;1140 117 145;1062 117 78;1055 118 6;1151 119 0;1217 118 126;1073 117 240;1006 168 67;863 168 140;655 168 208;579 168 76;339 168 240;575 101 52;464 94 111;288 97 176;300 101 84;129 10 171;27 99 102;0 97 69;0 93 77;0 97 174;0 168 69;930 168 52;1080 168 42;1079 169 1;1016 168 62;928 168 88;1348 168 60;1442 166 2;1631 169 3;1622 176 9;1480 178 142;1580 178 90;1560 178 20;1523 178 37;1437 178 86;1367 178 166;976 148 391;919 147 56;951 147 64;916 148 35;875 147 40;1526 148 21;1484 148 42;1389 148 95;1304 148 85;1356 147 140;1276 148 80;1185 148 91;1120 148 65;1146 148 166;1297 148 137;1123 148 174;1291 148 120;1198 178 93;1096 178 100;1055 127 137;1006 127 241;893 127 113;636 128 257;474 128 166;312 128 162;1121 128 247;1435 178 70;1296 135 139;1293 134 195;1087 134 206;819 135 268;760 135 59;1237 134 99;1366 175 63;1577 176 77;1345 218 232;1188 218 157;1081 219 107;1023 218 57;930 218 95;844 219 86;742 219 102;846 179 184;708 179 138;698 219 106;609 219 89;502 219 107;424 219 78;238 219 185;87 219 151;0 219 97;0 219 76;0 219 140;0 267 137;0 269 84;0 269 0;0 269 7;0 269 5;0 269 22;0 229 36;1655 229 36;2001 229 38;1905 229 95;1893 225 108;1823 229 70;1745 229 78;1668 229 77;1880 229 76;1821 229 59;1779 229 42;1637 229 142;1521 229 116;1848 229 57;1681 229 167;1527 229 154;1964 139 139;1772 139 192;2533 139 295;2222 139 311;1971 139 251;1594 139 377;1184 139 410;1023 139 161;1023 139 0;811 139 212;705 139 106;604 139 100;595 139 9;595 139 0;595 139 0;595 139 0;592 139 3;592 229 0;592 146 0;589 146 3;586 146 3;586 146 0;584 146 2;584 0 0;581 146 3;581 146 0;478 146 103;314 146 164;196 146 118;131 146 65;107 146 24;107 0 0;106 146 1;106 146 0;105 146 1;3213 146 60;3110 135 103;2847 139 263;2658 139 189;2461 139 197;2356 146 105;2227 146 129;2083 146 144;1910 179 173;1617 179 293;1398 179 219;1267 179 131;1083 179 184;817 179 266;815 218 98;1420 229 67;1335 229 85;1257 229 78;1185 219 71;1072 219 113;1894 219 138;1796 219 98;1700 219 96;1510 219 190;1510 219 105;1510 219 25;1909 219 47;1845 219 63;1806 219 39;1771 219 35;1982 219 77;1922 219 60;1870 219 52;1819 219 51;1782 219 37;1740 219 42;1651 219 89;1367 219 217;1170 219 197;1089 219 81;1607 219 58;1487 219 120;1423 219 64;1743 259 64;1667 259 76;1581 259 86;1867 259 98;1814 259 53;1774 259 38;1728 219 46;1779 219 45;1712 219 67;1660 219 52;1825 219 24;1774 219 51;1647 219 127;1572 219 75;1510 219 62;1478 199 128;1340 199 138;1554 199 74;1480 259 73;1380 259 100;1501 259 71;1402 259 99;1396 259 102;1339 259 57;1507 259 23;1760 259 35;1701 259 59;1660 259 41;1592 259 68;1508 259 84;1466 259 42;1659 259 95;1574 259 85;1472 259 102;1457 259 111;1344 259 113;1136 259 208;988 259 148;2017 259 123;1955 259 62;1825 259 129;1723 259 102;3917 259 110;3715 259 202;3571 259 144;3487 259 84;3360 189 127;3179 189 181;2911 189 268;2636 189 278;2402 189 234;2269 189 133;2178 189 91;2095 259 83;1956 259 139;1843 259 113;1702 259 141;1474 259 228;1311 259 163;1605 259 0;1768 257 125;1876 259 180;1846 188 222;1602 189 243;1196 189 408;1014 189 181;838 188 176;660 189 178;348 138 310;213 189 134;81 189 132;80 189 1;80 0 0;80 259 0;2383 259 0;2262 259 110;2181 259 81;2069 259 112;2069 259 186;1770 259 113;1684 259 86;1817 259 59;5946 259 94;5779 259 167;5535 259 244;5273 259 261;5085 259 187;4970 259 115;4831 259 139;4558 259 273;4323 259 235;4151 259 172;3828 259 323;3492 259 336;3365 259 127;3228 259 137;2979 259 249;2778 259 201;2507 181 271;2187 165 512;1870 166 317;1646 166 224;1407 163 239;1182 163 377;1423 169 239;1756 166 243;1318 166 438;985 168 334;836 259 149;803 259 32;2204 259 39;2738 259 42;2674 239 64;2504 239 170;2372 239 132;2249 239 123;2171 239 78;2041 239 130;1900 239 141;1653 239 247;1331 239 322;1135 239 196;963 239 172;1413 239 218;1965 239 216;1882 239 179;2234 239 32;2139 239 95;2061 239 78;1939 239 122;1967 189 164;1670 189 288;1532 189 138;1343 189 189;1022 189 321;813 189 209;1420 189 161;1359 189 157;1075 189 283;1015 239 60;917 239 98;1550 239 133;1420 239 130;1358 239 62;2893 239 97;3179 239 98;3071 239 108;4095 239 128;3825 239 270;3642 239 183];
b = [0;70;59;93;96;145;179;321;125;88;188;121;134;80;82;94;159;199;104;70;127;96;75;198;168;125;86;222;272;209;369;217;97;117;100;64;35;54;55;8;43;107;116;87;66;44;33;13;53;72;50;15;12;71;37;83;94;59;49;65;55;77;122;83;75;48;45;78;122;116;48;29;91;59;68;137;56;13;45;25;25;174;138;64;77;62;119;89;133;180;121;72;91;53;47;42;124;97;119;34;18;24;57;61;30;96;0;37;30;38;88;64;13;20;31;129;94;129;126;70;48;123;87;65;102;78;49;0;68;102;88;170;152;90;101;71;48;40;93;45;58;53;42;52;29;91;75;75;179;252;202;161;331;271;146;2;2;0;0;0;13;30;34;8;67;41;89;49;62;81;42;63;107;83;102;62;29;63;97;136;335;299;5;2;9;9;0;0;0;0;0;0;0;0;0;0;0;2;0;0;15;9;13;15;26;16;51;47;56;45;40;17;103;72;56;0;1;0;0;0;0;0;0;0;0;0;68;169;213;338;129;13;85;0;0;0;0;0;0;0;0;0;0;0;64;154;143;96;140;67;3;71;58;62;62;62;168;99;39;64;117;104;108;234;97;85;88;190;163;90;105;47;66;84;80;97;64;128;85;50;91;93;50;85;129;119;45;78;90;78;62;97;111;55;60;61;81;131;160;131;43;34;33;37;82;542;239;51;51;41;1;0;1;0;0;7;1;4;1;1;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;49;157;193;94;135;118;18;0;14;0;20;42;45;55;59;11;0;77;60;1;69;98;119;93;92;112;96;93;65;100;51;55;71;57;34;47;88;51;49;110;30;59;97;155;125;100;211;88;114;89;118;84;125;184;107;70;66;89;50;20;77;33;47;35;60;31;35;80;42;23;19;18;37;50;127;123;44;22;31;22;40;62;59;28;68;73;87;175;300;196;123;168;209;188;219;381;158;12;8;10;88;196;206;83;0;0;27;27;54;136;55;22;30;30;30;44;39;57;30;47;74;114;40;62;62;135;175;82;62;88;152;64;67;73;130;115;260;228;120;31;0;3;0;0;0;0;1;0;1;1;1;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;168;201;147;119;122;149;111;95;237;110;104;61;40;114;129;111;146;57;19;27;62;95;183;94;116;63;147;101;248;142;186;109;228;66;182;1;64;118;55;43;95;54;85;92;61;111;7;4;66;95;190;60;42;79;109;165;99;233;16;2;5;22;8;65;157;65;90;3;5;1;65;235;76;2;101;162;25;4;1;75;32;76;6;65;145;78;6;0;126;240;67;140;208;76;240;52;111;176;84;171;102;69;77;174;69;52;42;1;62;88;60;2;3;9;142;90;20;37;86;166;391;56;64;35;40;21;42;95;85;140;80;91;65;166;137;174;120;93;100;137;241;113;257;166;162;247;70;139;195;206;268;59;99;63;77;232;157;107;57;95;86;102;184;138;106;89;107;78;185;151;97;76;140;137;84;0;7;5;22;36;36;38;95;108;70;78;77;76;59;42;142;116;57;167;154;139;192;295;311;251;377;410;161;0;212;106;100;9;0;0;0;3;0;0;3;3;0;2;0;3;0;103;164;118;65;24;0;1;0;1;60;103;263;189;197;105;129;144;173;293;219;131;184;266;98;67;85;78;71;113;138;98;96;190;105;25;47;63;39;35;77;60;52;51;37;42;89;217;197;81;58;120;64;64;76;86;98;53;38;46;45;67;52;24;51;127;75;62;128;138;74;73;100;71;99;102;57;23;35;59;41;68;84;42;95;85;102;111;113;208;148;123;62;129;102;110;202;144;84;127;181;268;278;234;133;91;83;139;113;141;228;163;0;125;180;222;243;408;181;176;178;310;134;132;1;0;0;0;110;81;112;186;113;86;59;94;167;244;261;187;115;139;273;235;172;323;336;127;137;249;201;271;512;317;224;239;377;239;243;438;334;149;32;39;42;64;170;132;123;78;130;141;247;322;196;172;218;216;179;32;95;78;122;164;288;138;189;321;209;161;157;283;60;98;133;130;62;97;98;108;128;270;183];
X = tonndata(a,false,false);
T = tonndata(b,false,false);
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Nonlinear Autoregressive Network with External Input
inputDelays = 1:x(2);
feedbackDelays = 1:x(1);
hiddenLayerSize = x(2);
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
% Choose Input and Feedback Pre/Post-Processing Functions
% Settings for feedback input are automatically applied to feedback output
% For a list of all processing functions type: help nnprocess
% Customize input parameters at: net.inputs{i}.processParam
% Customize output parameters at: net.outputs{i}.processParam
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.inputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Prepare the Data for Training and Simulation
% The function PREPARETS prepares timeseries data for a particular network,
% shifting time by the minimum amount to fill input states and layer
% states. Using PREPARETS allows you to keep your original time series data
% unchanged, while easily customizing it for networks with differing
% numbers of delays, with open loop or closed loop feedback modes.
[x,xi,ai,t] = preparets(net,X,{},T);
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'time'; % Divide up every sample
net.divideParam.trainRatio = x(3)/100;
net.divideParam.valRatio = ((1-x(3))/2)/100;
net.divideParam.testRatio = ((1-x(3))/2)/100;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'mse'; % Mean Squared Error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate', 'ploterrhist', ...
'plotregression', 'plotresponse', 'ploterrcorr', 'plotinerrcorr'};
% Train the Network
[net,tr] = train(net,x,t,xi,ai);
% Test the Network
y = net(x,xi,ai);
e = gsubtract(t,y);
performance = perform(net,t,y)
% Recalculate Training, Validation and Test Performance
trainTargets = gmultiply(t,tr.trainMask);
valTargets = gmultiply(t,tr.valMask);
testTargets = gmultiply(t,tr.testMask);
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotresponse(t,y)
%figure, ploterrcorr(e)
%figure, plotinerrcorr(x,e)
% Closed Loop Network
% Use this network to do multi-step prediction.
% The function CLOSELOOP replaces the feedback input with a direct
% connection from the outout layer.
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
view(netc)
[xc,xic,aic,tc] = preparets(netc,X,{},T);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(net,tc,yc)
% Multi-step Prediction
% Sometimes it is useful to simulate a network in open-loop form for as
% long as there is known output data, and then switch to closed-loop form
% to perform multistep prediction while providing only the external input.
% Here all but 5 timesteps of the input series and target series are used
% to simulate the network in open-loop form, taking advantage of the higher
% accuracy that providing the target series produces:
numTimesteps = size(x,2);
knownOutputTimesteps = 1:(numTimesteps-5);
predictOutputTimesteps = (numTimesteps-4):numTimesteps;
X1 = X(:,knownOutputTimesteps);
T1 = T(:,knownOutputTimesteps);
[x1,xio,aio] = preparets(net,X1,{},T1);
[y1,xfo,afo] = net(x1,xio,aio);
% Next the the network and its final states will be converted to
% closed-loop form to make five predictions with only the five inputs
% provided.
x2 = X(1,predictOutputTimesteps);
[netc,xic,aic] = closeloop(net,xfo,afo);
[y2,xfc,afc] = netc(x2,xic,aic);
multiStepPerformance = perform(net,T(1,predictOutputTimesteps),y2)
% Alternate predictions can be made for different values of x2, or further
% predictions can be made by continuing simulation with additional external
% inputs and the last closed-loop states xfc and afc.
% Step-Ahead Prediction Network
% For some applications it helps to get the prediction a timestep early.
% The original network returns predicted y(t+1) at the same time it is
% given y(t+1). For some applications such as decision making, it would
% help to have predicted y(t+1) once y(t) is available, but before the
% actual y(t+1) occurs. The network can be made to return its output a
% timestep early by removing one delay so that its minimal tap delay is now
% 0 instead of 1. The new network returns the same outputs as the original
% network, but outputs are shifted left one timestep.
nets = removedelay(net);
nets.name = [net.name ' - Predict One Step Ahead'];
view(nets)
[xs,xis,ais,ts] = preparets(nets,X,{},T);
ys = nets(xs,xis,ais);
stepAheadPerformance = perform(nets,ts,ys)
% Deployment
% Change the (false) values to (true) to enable the following code blocks.
% See the help for each generation function for more information.
if (false)
% Generate MATLAB function for neural network for application
% deployment in MATLAB scripts or with MATLAB Compiler and Builder
% tools, or simply to examine the calculations your trained neural
% network performs.
genFunction(net,'myNeuralNetworkFunction');
y = myNeuralNetworkFunction(x,xi,ai);
end
if (false)
% Generate a matrix-only MATLAB function for neural network code
% generation with MATLAB Coder tools.
genFunction(net,'myNeuralNetworkFunction','MatrixOnly','yes');
x1 = cell2mat(x(1,:));
x2 = cell2mat(x(2,:));
xi1 = cell2mat(xi(1,:));
xi2 = cell2mat(xi(2,:));
y = myNeuralNetworkFunction(x1,x2,xi1,xi2);
end
if (false)
% Generate a Simulink diagram for simulation or deployment with.
% Simulink Coder tools.
gensim(net);
end
y = mean(abs(cell2mat(e)))
end
The following message is generated when using optimtool to optimize hyperparameters of the NARX network: Undefined function 'mrdivide' for input arguments of type 'cell'.
  1 Comment
Athrey Ranjith Krishnanunni
Edited: Athrey Ranjith Krishnanunni on 7 Jan 2021
Please mention the complete error message, specifically the line number.

Sign in to comment.

Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!