Tabulate variable inside a for loop

I want to tabulate x1 and x2 for eah iteration as shown in below. Which commaned will help me to get this. I am quite new in Matlab.
ind =1;
L=length (x);
for i=1:100:L
newx = x(ind:i-1);
newy = y(ind:i-1);
Lx=mean(x(ind:i-1));
Ly=mean(y(ind:i-1));
x1=newx-Lx;
y1=newy-Ly;
ind = i;
end;

 采纳的回答

Here's one way to do what I believe you want to do:
x = rand(1,1000);
y = rand(1,1000);
ind =1;
L=length (x); % assuming L is a multiple of 100
x1 = [];
y1 = [];
for i=101:100:L+1
newx = x(ind:i-1);
newy = y(ind:i-1);
Lx=mean(x(ind:i-1));
Ly=mean(y(ind:i-1));
x1(end+1,:)=newx-Lx;
y1(end+1,:)=newy-Ly;
ind = i;
end;
disp(x1);
Columns 1 through 22 0.3148 -0.3975 0.1281 -0.2767 -0.2194 -0.1161 0.1210 0.0276 -0.4236 -0.3020 -0.0042 -0.4239 -0.1775 -0.1776 0.4269 -0.2033 -0.4734 0.0445 0.1847 -0.2357 0.4635 -0.1503 0.4794 0.3422 -0.2818 -0.4757 0.4601 0.0646 -0.0467 0.3974 -0.0946 -0.1701 -0.3292 0.2901 0.0559 -0.0673 -0.1267 0.2735 -0.1436 -0.0895 -0.0711 0.0441 0.2645 0.1735 0.4696 -0.2917 -0.1429 0.4848 -0.2920 0.3159 0.2257 0.0584 -0.3024 -0.2362 0.1403 -0.0110 0.2870 -0.1082 0.2105 -0.3070 0.2368 0.0516 -0.0300 0.2130 0.2745 -0.2359 -0.3707 0.3040 0.3383 0.4309 -0.2801 0.5129 -0.1608 -0.1926 0.4636 0.3640 -0.4646 -0.3648 -0.3092 0.0477 -0.3391 -0.2309 -0.4570 0.2991 0.4438 -0.4191 0.1549 0.5033 -0.0552 -0.2184 -0.4610 0.3889 0.0256 0.1734 -0.1943 -0.0597 0.1278 -0.1507 0.4058 0.3408 -0.1043 0.1773 0.3675 0.2017 0.2052 0.0764 -0.1873 -0.1930 -0.3220 -0.0640 0.2793 -0.1294 0.0847 -0.0451 -0.1988 -0.1914 -0.3786 0.2918 0.2061 0.4963 0.4585 -0.4463 -0.0189 -0.4124 -0.2092 -0.0804 -0.4316 -0.4291 -0.2299 0.5202 -0.0520 -0.1214 0.2059 0.1206 0.3186 0.4535 0.1670 0.0042 -0.2775 0.0409 -0.1190 -0.4343 -0.4016 -0.0096 0.4549 0.0317 -0.0472 -0.1437 -0.0308 -0.0625 0.3605 -0.2641 -0.2852 -0.4461 -0.1814 0.2638 0.0589 0.4477 0.2078 -0.3068 -0.3760 0.2115 0.2680 -0.3878 0.3999 0.1048 0.3927 0.1930 0.5088 -0.0788 0.3525 0.5013 0.2675 -0.3184 -0.1214 0.3831 0.0487 0.4029 0.3437 0.4019 0.4903 0.3225 -0.2983 -0.0742 -0.0935 -0.1337 -0.2653 0.5157 0.3053 0.3875 0.0832 -0.2685 -0.0987 -0.4111 -0.0569 -0.0847 0.4368 0.3907 0.1718 0.2789 0.0236 -0.1703 0.1649 0.1846 -0.1925 -0.2691 0.1840 0.4219 -0.1507 0.1682 0.4115 0.3330 -0.1475 0.3369 0.1901 0.0930 0.1432 0.1847 -0.3208 -0.2145 Columns 23 through 44 0.2865 0.2284 0.1389 0.2517 -0.2718 0.3322 0.4700 0.0790 0.3463 -0.4406 0.3662 0.4220 -0.4099 -0.2563 -0.1928 -0.2668 0.1649 0.3008 -0.3594 -0.0740 0.3310 0.4422 -0.1949 -0.1785 -0.0086 -0.0547 0.1353 0.4096 -0.1730 0.2539 -0.5123 -0.1646 0.4229 -0.0564 -0.2152 0.1271 -0.0040 0.1964 0.2036 -0.2121 0.2337 0.3120 -0.3404 0.4283 -0.3307 -0.2383 -0.2161 -0.1051 -0.3213 -0.0299 0.1708 -0.1501 -0.4107 -0.3289 -0.3170 0.3511 0.5139 0.3115 0.1137 0.0062 -0.1371 -0.0305 -0.1142 -0.3554 -0.2208 -0.4315 0.2490 -0.2655 0.2977 -0.1759 0.3586 -0.3551 -0.3851 -0.3285 0.1651 -0.4000 -0.1280 -0.0091 0.1564 -0.3731 -0.4622 0.3460 0.1066 0.0396 -0.4333 -0.0716 0.2639 -0.1505 0.1741 0.4201 0.2470 0.3012 0.0843 0.2619 -0.3768 -0.0487 -0.3445 -0.0026 0.2226 -0.0550 -0.4512 -0.1806 0.1847 -0.1552 0.2084 0.5207 -0.1401 -0.0282 0.4926 -0.1468 0.2474 -0.1724 0.2374 -0.0919 0.4840 0.0456 -0.4626 -0.3487 -0.2722 0.0116 0.0056 -0.3589 -0.1584 -0.0408 0.3204 -0.2780 0.2694 -0.1074 0.4323 0.3866 -0.3404 0.1067 -0.2254 0.1691 -0.0766 0.3398 0.4292 0.3421 0.2919 0.4076 -0.1153 -0.1034 0.0587 -0.3006 0.3461 -0.2889 0.3715 0.4631 -0.0072 0.2717 -0.0723 -0.5321 0.1023 0.1994 -0.1228 -0.1909 -0.1904 -0.3378 -0.3119 0.0477 -0.4508 0.0639 -0.4620 -0.4641 0.1465 -0.3729 -0.2356 -0.1078 -0.2145 -0.1664 0.2073 0.4552 0.4144 0.2597 -0.1269 -0.1848 0.1741 0.2605 0.1840 0.2004 -0.0260 -0.2643 -0.1701 -0.4622 -0.1891 -0.4006 -0.4247 -0.4094 0.0690 -0.1297 0.3309 0.5092 0.4399 -0.1094 0.2725 -0.2585 0.1777 -0.4365 -0.3034 0.3078 0.3542 0.1977 -0.0938 0.1484 -0.2426 0.2923 -0.0162 -0.2061 -0.2605 0.1793 -0.2714 -0.0008 0.1066 -0.0830 0.1107 -0.3427 0.4239 -0.1426 -0.0341 -0.4577 Columns 45 through 66 0.1471 0.0474 -0.2102 -0.1517 0.3506 -0.2131 0.2912 -0.4114 0.3885 0.1640 -0.1690 -0.1530 0.2173 0.3159 0.0562 -0.2783 0.1263 -0.4543 0.3349 -0.0666 0.4103 -0.2357 -0.2217 0.0036 0.3576 0.2524 -0.4347 0.0254 -0.2214 0.4103 -0.0357 -0.2663 -0.2518 -0.2387 0.0312 -0.4718 -0.3094 0.1539 0.2490 -0.3031 -0.0541 -0.1976 -0.1515 0.4270 0.4606 -0.3327 -0.3994 0.4514 -0.1214 -0.1067 -0.4171 0.2165 0.1915 -0.2884 -0.0675 0.3315 0.4139 -0.2165 0.2576 0.0969 -0.0798 0.2433 0.1052 0.2307 -0.4406 0.0526 -0.1446 -0.0018 -0.2141 -0.0014 0.4931 -0.4158 -0.3932 -0.2146 -0.1545 -0.4269 0.5169 0.0897 -0.3534 -0.3949 0.2759 0.0343 0.0169 0.3408 -0.0434 -0.0997 -0.4240 -0.3211 0.0558 -0.2194 0.5020 -0.0639 -0.0907 0.2906 -0.0714 -0.2017 0.4949 0.0110 0.0851 0.0247 0.4985 0.0100 -0.2862 -0.1482 -0.4147 0.5095 -0.3417 -0.0586 0.0693 0.5222 -0.0483 0.1040 0.4408 -0.1934 -0.0126 -0.1316 0.2547 0.1796 0.1267 -0.3382 -0.3451 0.4629 0.4660 0.4425 0.4016 0.1717 -0.4559 -0.1933 -0.0993 0.0836 0.1974 -0.2928 -0.2798 -0.2159 0.2177 0.0885 -0.3100 -0.0131 0.0560 -0.4554 -0.4112 -0.1579 0.2979 -0.3755 0.4223 -0.4011 -0.4425 0.1248 -0.3560 -0.3434 -0.4221 -0.1441 0.0382 0.1531 0.4319 0.1846 0.4563 -0.1808 0.5160 0.1688 0.2248 -0.4594 -0.3495 -0.4412 0.1163 0.1425 -0.2304 0.4546 0.4961 0.1146 -0.4085 0.2258 0.1100 -0.1988 -0.2224 0.2526 -0.0462 -0.0033 0.1585 -0.3948 -0.0406 -0.0422 0.0591 -0.2533 -0.2529 0.0194 0.0159 -0.2031 0.1963 -0.2712 -0.2848 0.4073 0.0979 -0.3823 -0.0244 0.1013 0.1868 0.0847 -0.1843 0.3200 0.4653 -0.0573 0.4622 0.1234 0.4098 -0.0387 -0.2120 -0.4633 -0.4318 0.4878 -0.0031 -0.3707 -0.1607 -0.4425 -0.0999 0.2251 -0.2838 -0.3070 -0.3381 -0.2513 Columns 67 through 88 0.1870 -0.0975 -0.4552 -0.0412 0.1064 0.2244 0.1317 0.1127 -0.2153 0.4145 -0.2358 0.3560 0.3515 -0.4242 -0.0358 -0.4959 0.0105 -0.5015 -0.2402 -0.3264 -0.1011 -0.3019 -0.1576 0.4267 0.0165 0.4247 0.0070 0.1130 -0.4298 0.0335 0.1089 0.4320 0.4241 0.2414 -0.3618 -0.2124 -0.4926 -0.1857 0.3239 -0.1503 -0.1128 0.4343 0.0975 0.3441 -0.2207 -0.3970 0.0392 0.1075 -0.1547 -0.3633 -0.3153 -0.1759 0.3126 0.5027 -0.0612 0.1059 -0.0323 -0.2734 0.2225 -0.2736 -0.4630 -0.1663 0.5105 0.0185 -0.2267 -0.2754 -0.0330 0.1006 -0.0355 0.4622 -0.1892 0.1446 0.2615 -0.3217 -0.1139 0.4387 -0.1013 0.2198 -0.3491 0.2814 0.4133 0.4746 0.4948 -0.2437 -0.1872 -0.4040 0.0378 0.3749 -0.3985 0.2757 0.4175 0.2839 -0.3782 -0.4634 -0.3599 -0.3893 -0.1001 -0.2888 -0.3656 0.1231 -0.4170 -0.0100 -0.3952 0.1688 0.0663 -0.3147 -0.2514 -0.2909 -0.1450 -0.0831 -0.1190 -0.0039 0.3175 -0.3409 0.4345 -0.3623 -0.0890 0.3772 0.4659 0.1250 0.4370 0.1772 -0.1535 -0.3271 0.2984 0.1441 -0.4461 -0.4749 -0.3479 0.1343 -0.4323 -0.3584 -0.3759 -0.0271 0.4439 -0.0536 -0.3509 0.0508 -0.2163 0.2679 0.4040 -0.0176 0.3457 0.1626 0.1635 -0.3597 0.3689 0.1858 0.1905 0.4268 0.0097 0.1091 -0.2093 0.1066 -0.4036 -0.4324 -0.4016 -0.3717 -0.2265 -0.0113 -0.1419 0.4725 -0.2662 0.4078 -0.4049 0.1809 0.2533 0.2253 -0.3019 0.0596 -0.1345 -0.2029 -0.2431 0.5079 0.3860 0.0713 0.2139 -0.4142 0.2263 0.1496 0.0193 -0.2714 -0.4058 0.2419 0.4397 0.4310 -0.2491 0.0319 -0.1488 0.0886 -0.1744 0.1731 -0.1869 -0.4659 0.0574 0.1032 -0.0152 0.0747 -0.3397 0.3831 0.0439 -0.3765 0.0544 -0.1392 -0.2647 0.0567 -0.3690 -0.1627 0.3268 -0.4201 -0.2881 -0.2248 0.3316 0.3284 -0.1156 -0.3905 0.2248 -0.2053 -0.0373 -0.1638 Columns 89 through 100 -0.2011 -0.2409 -0.2382 0.1785 0.1409 0.1427 0.1829 0.4446 0.3665 0.3444 -0.3520 0.2846 -0.1979 0.3832 -0.3728 -0.4275 0.3358 -0.3617 -0.1393 0.1374 -0.2091 -0.2770 -0.1363 -0.3689 0.2537 0.1885 0.2625 0.3395 -0.3100 0.3875 0.4097 -0.4707 0.3428 0.3181 0.0739 0.4624 0.4494 0.4572 -0.0093 -0.1831 -0.0001 -0.0217 0.3951 0.4444 -0.4073 0.4601 -0.0492 -0.1440 0.2477 -0.1103 0.0787 0.3170 0.0136 -0.2361 -0.2446 0.2171 0.4249 0.0230 0.2016 -0.4623 0.4294 -0.1542 0.3310 0.0259 -0.0317 -0.4643 -0.2891 0.3362 -0.2118 0.3082 0.2889 -0.1229 0.0914 -0.2715 0.3527 -0.0535 0.4148 -0.0215 -0.3709 -0.4085 0.2537 -0.2521 -0.0286 -0.1084 -0.1472 -0.2220 -0.2838 -0.1556 0.1856 -0.1081 -0.2080 -0.2834 0.1815 -0.1698 0.1084 0.2311 0.2505 0.1499 -0.0329 0.2443 0.2662 -0.2165 -0.3803 -0.3748 -0.2698 -0.2496 -0.0725 -0.0429 0.3864 -0.3345 -0.1304 0.4677 0.1723 0.0748 0.5028 0.0004 0.5277 -0.3313 0.1658 -0.0938
disp(y1);
Columns 1 through 22 -0.5054 0.2759 0.3041 0.4005 -0.0356 -0.3790 0.2957 -0.4914 0.2889 -0.0109 0.2976 -0.2421 0.1595 -0.4999 -0.1981 0.2687 0.2812 0.4391 0.0677 -0.2218 0.4095 0.1410 -0.1590 -0.2395 0.3238 0.0685 -0.1122 0.2046 -0.1731 -0.0784 -0.0322 -0.4122 -0.1583 -0.0249 0.4793 -0.2253 0.1305 -0.4065 0.0095 0.0871 0.3820 0.4280 -0.2108 0.5275 0.1653 -0.0296 -0.1877 0.1598 0.4042 -0.0660 0.0056 -0.1025 0.3055 -0.0413 -0.1078 -0.3388 -0.1427 0.3053 -0.1293 0.5000 -0.1927 -0.3610 0.1895 0.3741 0.2165 -0.3979 0.3846 -0.2933 -0.0211 -0.4310 -0.4399 0.4247 0.1420 -0.4151 -0.2445 0.0104 0.0841 -0.2014 -0.3332 -0.4315 0.0332 -0.2506 0.4921 0.4022 0.1132 0.3650 -0.1292 0.1072 0.1025 0.2252 -0.4460 -0.3681 0.2909 0.4518 0.0222 -0.0507 -0.2722 -0.1063 -0.4621 -0.3743 0.1900 -0.1778 0.0381 -0.2614 0.2160 0.2589 -0.3590 0.2279 -0.0880 0.3004 -0.1937 -0.0933 0.3035 0.1572 -0.3909 0.0307 0.0320 -0.4204 -0.2000 -0.4706 -0.3520 -0.4133 -0.4477 0.4370 0.1980 -0.1325 0.1708 0.3818 0.2486 -0.4511 -0.4115 -0.2481 -0.1658 -0.4516 -0.4117 0.0326 0.2396 -0.3246 -0.2150 -0.1001 -0.2166 -0.1247 -0.0871 -0.2194 0.1829 -0.3477 -0.3593 -0.2087 0.2485 -0.4395 0.2003 -0.0493 -0.2660 0.1872 0.2917 0.1107 -0.0206 0.4827 -0.0157 0.0806 -0.2421 0.0628 -0.2624 0.2941 -0.1140 0.3425 0.2946 0.0544 0.0860 -0.1272 0.0373 0.4378 -0.3234 -0.3747 -0.1327 -0.0634 -0.3457 0.0520 -0.4046 0.0693 -0.2767 0.2697 -0.4769 0.4197 -0.3658 -0.2050 0.3147 -0.1201 -0.4481 -0.0439 -0.0029 0.2447 0.2167 -0.4629 -0.2844 -0.4069 0.2448 0.4330 -0.3784 0.4677 -0.3017 -0.1520 -0.1514 -0.1803 0.0523 0.1081 -0.2532 0.3624 0.1389 -0.2344 0.3193 0.2641 -0.4128 -0.2960 -0.4104 -0.2442 0.4963 -0.1105 -0.4193 -0.2987 Columns 23 through 44 0.0600 -0.4309 -0.3670 0.3120 -0.4907 0.0666 -0.4012 0.2837 0.1148 -0.3700 0.0127 -0.3436 0.3384 0.4086 -0.2731 -0.2689 0.3879 0.3986 0.1466 0.2377 0.4704 0.4322 -0.2359 0.3577 0.0267 0.0147 -0.0991 0.3787 0.0214 -0.0727 -0.0198 -0.4046 0.4258 -0.4391 -0.1237 0.2585 0.1810 -0.2538 -0.3082 -0.2992 -0.3813 -0.2417 -0.3185 -0.0110 0.0400 -0.3799 -0.0391 0.5092 0.0043 -0.0316 -0.2198 -0.2857 -0.3608 -0.4404 0.1735 -0.0348 0.1428 0.3868 0.0873 0.2105 0.1079 0.4434 0.3240 -0.3345 0.2245 0.0923 0.3656 0.4670 0.4475 0.1219 0.0494 0.2946 0.1169 -0.0359 0.1772 -0.1195 0.2717 -0.2874 -0.1988 -0.1814 0.1311 0.2988 0.3416 0.4433 -0.1432 -0.3976 -0.2152 -0.1056 0.0010 0.5050 -0.2041 -0.1895 -0.2859 -0.3614 0.1577 -0.2284 0.1626 -0.3114 -0.2690 0.3477 0.1610 0.2155 0.3283 -0.4544 0.4435 -0.0999 0.1347 -0.0836 -0.3904 0.3452 -0.0553 -0.2252 0.2631 -0.1801 0.1187 0.3605 0.4422 0.2045 -0.0744 -0.1067 0.4103 0.0915 0.3115 0.0324 -0.2755 -0.0251 -0.2677 0.4916 0.4223 -0.1589 -0.2141 -0.2816 0.2139 0.3470 -0.0063 -0.4111 0.4206 0.4460 -0.0332 -0.0971 0.4679 0.0209 0.5240 -0.0162 0.0168 -0.1592 0.4757 0.4124 -0.3338 0.0545 0.1013 0.3464 0.0066 0.1008 0.4524 -0.4751 0.4741 0.4014 -0.1979 -0.2950 0.4404 -0.3280 0.4896 -0.4200 0.1745 0.0148 0.0550 -0.2755 -0.3244 0.0082 -0.1284 -0.3882 -0.1443 0.4765 -0.4990 -0.0620 -0.0088 -0.3682 0.2849 -0.2874 0.4728 0.0878 0.4786 -0.2985 -0.3546 -0.3208 0.4459 -0.3194 -0.0999 -0.4052 0.4136 0.3850 0.1892 -0.1547 0.1192 0.2238 0.4691 0.3141 -0.2891 -0.0751 -0.1344 -0.1936 -0.1289 0.5201 0.1760 0.4325 0.5249 0.0230 0.4466 -0.2376 -0.1595 -0.2882 -0.3535 -0.4018 0.0574 -0.1677 -0.0692 0.3392 -0.1744 -0.2803 Columns 45 through 66 0.4426 0.2168 -0.0349 0.0677 0.3787 -0.2684 0.3246 0.2607 0.4705 -0.4248 -0.4920 0.1582 -0.4847 -0.3504 0.0548 -0.2859 -0.3801 0.3197 -0.1028 0.1103 0.4614 -0.4680 0.3840 -0.3368 0.4023 -0.2828 0.2493 0.0976 -0.2405 0.2813 0.3715 -0.1243 -0.2718 0.5063 -0.2253 0.5208 -0.2045 -0.0900 -0.1117 0.2979 -0.2580 0.2948 0.4300 -0.3544 -0.1332 -0.2427 0.0933 -0.4844 0.0107 -0.0197 -0.2909 0.4827 0.3017 0.4664 -0.0196 -0.4005 0.2853 0.1504 -0.0862 -0.0929 0.3494 -0.4480 -0.2874 0.0689 -0.1571 -0.4700 0.3917 -0.3202 0.3904 -0.3616 -0.0985 0.2460 0.3320 -0.0946 -0.3246 -0.2100 -0.0094 -0.4710 0.4274 0.1276 -0.3158 0.3488 -0.3011 -0.1172 -0.1051 0.3951 -0.3782 -0.3969 -0.4587 0.3304 -0.0591 -0.4160 -0.3316 0.0183 0.1578 -0.3518 -0.0934 0.2882 -0.3582 0.0314 0.2819 0.0030 -0.4377 0.1511 0.0285 0.0756 -0.1233 -0.0881 0.2600 -0.2748 0.2265 0.4901 0.1752 0.2344 0.3866 -0.1233 -0.4426 -0.1432 -0.0593 -0.1715 -0.2457 0.2321 -0.0679 0.0102 0.1795 -0.3285 -0.2752 0.4583 -0.1935 0.0299 0.2171 0.3902 -0.2251 -0.2303 -0.3467 -0.2055 -0.4324 0.1535 0.2051 0.1768 0.1355 0.0520 0.4320 -0.3835 -0.0496 -0.4068 0.1521 0.4669 0.3930 0.4573 -0.4291 0.3439 0.2872 0.1409 0.2019 0.3190 -0.0921 -0.1039 0.2721 0.1223 -0.2378 -0.3669 -0.3951 -0.2395 0.3478 0.2071 -0.5038 0.4343 0.2899 0.2491 -0.1288 0.2285 -0.3607 -0.1082 0.1234 0.1111 0.4791 -0.1419 0.0569 0.4536 -0.0034 0.3978 0.4848 0.2786 0.0247 0.4084 -0.4415 0.3037 -0.1014 -0.3693 0.2552 -0.4195 0.4954 0.3603 -0.2403 -0.2177 0.3667 0.0355 -0.2373 -0.0786 0.4973 0.2991 0.4228 -0.4161 -0.1952 -0.0441 -0.1989 -0.2195 -0.3499 -0.2710 0.3967 -0.2754 -0.2108 -0.3672 0.0040 -0.3583 0.2560 0.0582 0.3975 0.5444 Columns 67 through 88 -0.1607 -0.2151 0.3774 -0.1192 0.0754 -0.3157 0.2578 -0.5181 0.2060 -0.2398 -0.3866 0.0588 -0.3358 -0.4567 -0.5179 -0.0028 -0.4572 0.0642 0.0793 -0.2850 0.0790 0.3301 0.1431 -0.3748 -0.3515 -0.2017 -0.2653 0.4081 -0.0012 -0.4007 0.4564 -0.0159 0.0699 0.1034 0.1330 -0.2798 0.1783 -0.0647 0.1226 -0.1087 0.2239 0.3269 0.0169 0.3805 0.3032 0.5036 0.4653 -0.1011 -0.4158 -0.0559 -0.2240 -0.2106 0.1063 0.0611 -0.4586 0.3386 0.1327 -0.4397 0.5131 0.1218 0.0681 -0.0728 -0.1192 0.1692 0.0631 -0.1072 -0.0711 -0.3917 0.2793 -0.2155 -0.0431 -0.1447 0.2267 0.1075 -0.4672 -0.1347 -0.0731 -0.4605 0.4017 0.3706 -0.2751 0.4158 -0.2003 -0.0701 0.3632 -0.3233 0.3453 0.0779 0.2493 0.1528 0.3026 0.2308 0.0938 -0.1842 -0.0285 -0.2161 0.0464 0.1481 0.2486 0.4499 -0.1110 -0.4753 0.4920 -0.3378 0.1482 0.1926 -0.3333 0.1550 0.4537 -0.4293 0.1259 0.3245 0.1385 0.0650 -0.4704 0.0540 -0.2349 0.3010 -0.0239 0.0595 -0.4573 -0.3528 -0.3177 0.1749 0.2812 0.3667 -0.2852 0.4746 0.2077 -0.1892 0.3530 0.1682 -0.3821 -0.3216 -0.3833 0.0722 -0.1817 -0.3542 0.0104 -0.3999 -0.2539 0.1705 0.0733 0.1986 0.5186 -0.2044 0.0703 -0.1002 -0.2029 -0.2537 0.2679 0.5236 -0.2580 0.0289 -0.4316 0.1502 -0.4320 0.4366 -0.2953 -0.2297 0.0353 0.2175 -0.4915 -0.2579 0.3703 -0.1674 -0.2742 -0.1846 -0.0666 -0.0023 0.3544 0.3853 0.4248 -0.1536 -0.0347 -0.1845 -0.2816 -0.2645 0.1654 -0.0059 0.1989 0.0872 -0.1159 -0.0915 -0.2645 -0.3901 -0.2286 -0.0994 -0.1786 0.3765 0.3578 0.2786 0.3014 -0.2042 -0.1315 0.4103 -0.3905 -0.3529 -0.1897 -0.3041 0.3658 -0.1367 0.1561 0.5247 0.2614 -0.2734 0.3901 -0.1081 0.2645 -0.1628 -0.2180 -0.4079 0.4471 0.4157 -0.0423 -0.0727 0.5248 -0.1253 0.4170 0.2620 Columns 89 through 100 0.0624 -0.2115 0.4442 0.2942 0.1271 0.3240 -0.5169 0.0052 0.1981 0.4544 -0.3880 -0.0545 -0.2465 -0.3914 0.4777 0.1807 -0.2034 -0.0117 -0.4219 -0.3797 0.0689 0.3541 0.1262 -0.2520 0.2566 -0.0626 -0.4713 0.0957 0.1511 -0.3664 -0.2861 -0.2086 0.3853 0.4215 -0.4123 -0.3684 0.4082 0.1966 0.3580 -0.3940 -0.2623 -0.1390 0.4022 0.4271 -0.4037 0.0492 -0.3988 -0.3257 0.1101 -0.1571 -0.0723 0.3769 -0.2064 0.4133 0.4882 0.1982 -0.3757 0.2291 0.2429 -0.4115 0.2673 0.1157 -0.1693 -0.3956 0.4749 -0.4824 0.1709 -0.1802 -0.1538 -0.2295 -0.2553 0.0757 0.2472 -0.3831 -0.4163 0.4026 -0.0633 0.2938 0.3948 0.3257 0.1869 -0.2852 0.1350 -0.1654 0.2210 -0.1668 0.0922 0.0749 -0.0599 -0.4636 0.3392 0.0716 -0.2259 -0.2597 0.4837 0.0070 -0.0050 0.0927 -0.2177 0.2682 -0.3889 -0.3850 -0.3183 -0.4433 0.5047 -0.2592 -0.0878 -0.0896 -0.2129 0.3556 -0.1673 0.4359 -0.0885 -0.2394 0.5002 -0.3042 -0.1560 -0.1917 0.2874 0.2071

5 个评论

Thank you Benjamin.
Could you please help me to Tabulate as a Table showing all x1 and y1 in two column?
Thanks
I'm not sure what you mean by x2, but I'll keep assuming that means y1. To get x1 and y1 in a table as columns, with the elements in each in the same order as the corresponding elements are in x and y:
x1 = reshape(x1.',[],1);
y1 = reshape(y1.',[],1);
t = table(x1,y1);
To put x1 and y1 as columns in a matrix instead of a table:
x1 = reshape(x1.',[],1);
y1 = reshape(y1.',[],1);
m = [x1 y1];
Thank you. I am wondering if I use i=101:100:L+1, I am loosing some data. For exmple I have 2890 experimental data but after the run I am getting 2801 data.
I made i start at 101 to avoid the first iteration of the loop not doing anything (ind:i-1 is empty when i and ind are both 1).
The reason you end up with less data is not because of the 101, but because L is not a multiple of 100. Notice the comment I put in the answer:
% assuming L is a multiple of 100
If L is not a multiple of 100, you're going to lose some data when you group it into blocks of 100 like this. But the code can be modified to handle a partial block on the end. One way to do so is to pad x and y with NaNs so that you have a multiple of 100 data points and then remove the extra NaNs at the end after making x1 and y1 into column vectors:
x = rand(1,2890);
y = rand(1,2890);
ind =1;
L=length (x);
rem_L = rem(L,100);
if rem_L > 0
x = [x NaN(1,100-rem_L)];
y = [y NaN(1,100-rem_L)];
use_L = L+100-rem_L;
else
use_L = L;
end
x1 = [];
y1 = [];
for i=101:100:use_L+1
newx = x(ind:i-1);
newy = y(ind:i-1);
Lx=mean(x(ind:i-1),'omitnan');
Ly=mean(y(ind:i-1),'omitnan');
x1(end+1,:)=newx-Lx;
y1(end+1,:)=newy-Ly;
ind = i;
end;
% reshape to columns
x1 = reshape(x1.',[],1);
y1 = reshape(y1.',[],1);
disp([x1(end-19:end) y1(end-19:end)]);
0.3917 -0.4715 0.4811 -0.2362 0.3720 0.2298 -0.3582 0.5000 0.4065 0.2228 0.3538 0.2284 0.4676 0.4206 -0.4198 -0.3384 -0.4675 0.4203 0.1805 0.3087 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
% cut off the extra NaNs:
x1 = x1(1:L);
y1 = y1(1:L);
disp([x1(end-19:end) y1(end-19:end)]);
0.2600 -0.3869 0.2752 -0.0628 -0.3720 -0.1492 0.0685 -0.4139 0.1744 0.4079 -0.1341 0.1483 0.3024 -0.1900 0.3257 0.2101 0.1395 0.3611 0.0213 0.0902 0.3917 -0.4715 0.4811 -0.2362 0.3720 0.2298 -0.3582 0.5000 0.4065 0.2228 0.3538 0.2284 0.4676 0.4206 -0.4198 -0.3384 -0.4675 0.4203 0.1805 0.3087

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by