I want to find the minimum of the function in GA to find the values of x. I created a matrix A (70*5) and wrote the function, but after running the GA, the x values are not correct. Is it (fitness function) correct?

function f = simple_fitness(x)

A=[316.7626539 303.3578237 961.6575241 337.2092928 94.6;

137.0433216 190.377636 405.7016489 269.4694834 111.7;

403.6327687 376.3838651 850.0852505 367.4649825 265.3;

266.0557972 168.6624987 514.2429264 128.8305979 237.0;

246.9758995 300.1500678 508.61224 224.2618123 381.6;

338.9456831 328.8217116 961.1093347 373.7654025 190.7;

285.5705355 387.824929 845.8574201 416.2215524 509.7;

285.7322054 382.7136082 376.0398348 232.0847094 163.2;

60.94520673 504.4435148 409.3789356 477.1316661 532.9;

142.450641 180.0703572 380.8780844 180.9126415 232.9;

311.183028 178.9851066 351.3553968 201.6853578 75.4;

231.515141 173.1289053 534.0486375 166.7974282 176.9;

530.8081226 860.8543631 1140.293834 808.0395246 117.3;

191.864544 238.1365323 508.5232394 114.8880213 306.7;

374.1264028 367.0760616 1139.23151 264.0211494 81.4;

302.5424195 349.8440618 416.592934 424.9589701 414.5;

110.7396575 147.3785943 382.4938256 224.153671 80.7;

276.1470996 199.1815368 340.6346724 216.8766959 99.0;

115.1376747 169.7602401 377.4899423 226.7852687 83.8;

146.0560014 182.2560591 364.5698813 169.0558317 118.7;

364.1644753 301.8926488 686.988192 368.1643614 124.0;

382.5270934 248.2526523 740.0773075 408.2022868 222.6;

398.4594989 311.5058112 1036.947919 386.7835726 271.7;

734.6799946 796.466613 1144.232964 738.0273979 270.0;

605.0667735 669.6021081 1160.148843 602.8169181 174.5;

124.5606764 152.3728389 467.923877 158.9729549 143.0;

681.9464481 611.6044791 1445.47763 817.3457145 612.1;

305.9601778 208.4423203 1255.227364 136.5695954 432.7;

1516.07238 1788.088851 1328.598439 1472.918865 1497.5;

2754.602924 2798.928652 1459.85 2614.438019 2800.0;

2269.181412 2345.991037 1215.402366 2202.565876 2321.5;

327.7053159 485.039461 594.7632718 515.2253408 400.0;

372.7843048 476.699024 1174.110871 408.6889789 661.0;

1442.531262 1352.322773 1196.355255 1494.432629 1318.0;

467.3125309 390.7198165 678.3332211 410.6495877 553.0;

343.6173818 540.6854695 1182.815163 394.225525 563.0;

325.958484 214.824587 348.2774766 226.550073 241.0;

262.7118317 191.6752337 377.1790592 170.9270145 257.0;

288.832652 699.036677 632.8128629 847.5446491 885.5;

279.8156452 75.60398239 496.3315453 13.05584332 40.7;

439.2988658 336.2532111 571.5381751 521.0966084 325.0;

279.7976239 36.35408812 514.1520951 63.07298754 80.0;

2030.145387 1963.398022 1213.567174 2090.847461 2025.0;

778.8707556 743.1882188 1161.244574 823.2251663 1147.0;

658.0613959 694.5398724 1201.87063 726.534841 840.0;

884.7159559 873.4369642 1325.528773 630.8994755 853.0;

372.354821 468.3429359 492.2465708 458.0452084 518.0;

266.1491852 211.7637567 362.026381 223.9987793 346.0;

435.2976195 393.1296315 1179.190209 287.5876043 579.0;

745.655746 720.5475937 1379.776763 904.6412664 760.0;

1060.396279 1090.428348 1191.276953 1373.209721 1486.0;

273.2302965 315.530041 789.0791549 172.1676098 86.4;

655.1300643 813.0738677 1189.590962 739.1904211 1296.0;

287.8399372 437.8706863 851.7614621 391.7428388 80.0;

657.5178944 639.4980112 1112.279916 581.6465257 710.0;

662.8299012 707.3526727 1317.64759 576.7251596 689.3;

417.8114895 434.7114516 1019.254879 412.7636494 987.9;

325.0156633 146.9009606 871.3138124 397.2320491 170.6;

119.5162325 106.8205707 480.842798 236.4167669 70.4;

285.4989116 387.1277964 845.8574201 416.089543 727.7;

291.6529578 297.9626571 906.2924125 195.9043984 265.6;

341.9063567 263.0328678 1190.155048 133.7030761 169.6;

2667.871352 2803.986485 1459.85 2851.736185 2800.0;

2768.952289 2875.145392 1459.85 2904.32357 2879.0;

323.2200114 373.5511513 638.8234642 315.8957268 809.0;

349.0296173 249.1168443 416.4372719 77.75868469 270.0;

374.2546852 352.3715148 1236.300428 478.1740085 147.0;

107.9588485 163.3857133 363.348985 230.7611383 138.0;

971.5750297 983.9590704 1177.419044 1202.403727 1371.3;

311.7549784 274.7452781 1098.561085 251.1600602 90.7;]

f=symsum((1/70)*((x(1)*A(n,1)+x(2)*A(n,2)+x(3)*A(n,3)+x(4)*A(n,4)-A(n,5)).^2),n,1,70);

Similar questions and discussions