How to make 3 arrays (Test , Test2, Test3) that are of different lengths into one matrix?

1 回表示 (過去 30 日間)
Marc Daniel
Marc Daniel 2022 年 6 月 24 日
コメント済み: Voss 2022 年 6 月 24 日
Test = [6,6,6,6,6,6,6,6,6,6,6,6,12,12,12,12,12,18,18,18,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,30,30,36,36,36,36,36,36,36,36,36,42,42,42,42,48,48,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,60,60,66,66,66,66,66,66,66,66,66,72,72,78,78,78,84,84,84,84,84,90,90,102,120,120,126,126,132,132,138,138,138,150,156,156,156,168,180,180,180,180,180,180,186,192,192,198,198,204,204,204,204,210,210,210,210,210,210,210,210,216,216,222,228,228,228,228,228,234,234,234,240,246,246,252,258,282,282,282,282,282,282,282,282,282,294,294,294,300,300,306,312,312,318,318,318,324,324,330,330,330,330,330,330,330,348,360,360,360,360,360,366,366,366,366,366,372,378,396,396,402,408,408,408,414,414,420,420,420,420,426,426,432,432,450,456,462,468,468,468,474,480,480,480,492,492,492,492,492,498,516,516,522,534,534,540,552,558,558,558,564,582,600,600,600,606,612,618,618,624,630,630,636,642,648,654,654,654,654,672,678,696,696,702,714,720,726,738,744,750,750,756,762,774,780,792,798,798,804,816,816,834,840,846,852,852,870,870,870,882,900,912,912,912,912,912,912,912,918,930,936,942,954,960,960,966,978,984,999,1014,1020,1032,1032,1044,1059,1071,1077,1083,1125,1137,1149,1149,1155,1167,1191,1197,1197,1203,1209,1224,1224,1245,1260,1266,1308,1314,1314,1347,1353,1365,1380,1416,1422,1437,1464,1464,1470,1485,1512,1518,1536,1542,1575,1581,1602,1602,1614,1626,1656,1656,1686,1728,1770,1785,1791,1806,1842,1854,1881,1881,1881,1923,1923,1935,1965,1965,1971,1983,1983,1995,2013,2013,2013,2025,2031,2052,2073,2118,2133,2151,2214,2244,2286,2307,2328,2334,2361,2391,2397,2403,2403,2409,2424,2430,2430,2466,2481,2532,2538,2568,2568,2574,2598,2604,2625,2658,2709,2715,2730,2772,2778,2823,2850,2871,2886,2913,2949,3021,3042,3042,3108,3144,3177,3219,3270,3291,3309,3336,3363,3399,3435,3471,3510,3540,3540,3576,3609,3645,3678,3699,3714,3726,3741,3804,3831,3867,3873,3888,3915,3936,3963,4005,4038,4053,4074,4074,4080,4086,4086,4092,4092,4098,4122,4137,4224,4254,4275,4320,4326,4347,4374,4419,4452,4443,4449,4464,4434,4440,4404,4371,4401,4407,4422,4422,4470,4494,4503,4485,4506,4515,4515,4491,4503,4491,4425,4476,4491,4512,4518,4503,4491,4503,4548,4614,4593,4623,4572,4578,4572,4587,4593,4590,4605,4605,4659,4668,4722,4716,4701,4710,4686,4659,4614,4572,4581,4590,4596,4596,4602,4608,4596,4650,4635,4644,4623,4608,4608,4641,4647,4617,4626,4641,4665,4614,4605,4596,4593,4617,4614,4629,4629,4617,4626,4617,4587,4572,4491,4482,4452,4446,4407,4419,4431,4476,4425,4416,4422,4440,4434,4449,4392,4416,4383,4383,4407,4350,4377,4386,4371,4371,4371,4284,4290,4275,4305,4293,4296,4293,4317,4284,4275,4251,4251,4287,4302,4311,4314,4266,4275,4233,4221,4230,4191,4146,4098,4113,4128,4182,4110,4104,4110,4146,4155,4182,4197,4191,4266,4215,4212,4224,4230,4245,4245,4263,4299,4272,4302,4302,4323,4317,4347,4317,4311,4323,4317,4287,4302,4272,4287,4254,4263,4275,4233,4272,4257,4197,4191,4155,4119,4164,4218,4209,4197,4176,4191,4140,4131,4119,4059,3999,4014,4020,4014,4002,3993,3981,3996,3981,3987,3960,3954,3981,3969,3993,3966,3966,3990,4014,3999,3993,3963,3948,3948,3945,3960,3948,3936,4002,4011,3990,4005,4020,4029,4047,3981,3936,3951,3966,3951,3942,3891,3825,3861,3849,3849,3849,3840,3750,3714,3741,3765,3786,3786,3756,3714,3702,3702,3708,3684,3684,3681,3708,3744,3738,3702,3696,3696,3696,3669,3666,3630,3615,3624,3591,3612,3612,3642,3597,3600,3624,3633,3642,3624,3639,3618,3633,3621,3609,3546,3534,3540,3555,3537,3534,3513,3552,3546,3516,3477,3507,3531,3564,3558,3507,3552,3528,3528,3534,3543,3540,3525,3507,3492,3513,3480,3399,3357,3393,3363,3342,3363,3348,3339,3333,3333,3327,3378,3333,3375,3348,3348,3357,3336,3348,3348,3327,3312,3306,3309,3288,3279,3300,3258,3282,3234,3234,3228,3252,3237,3222,3210,3189,3189,3174,3150,3165,3180,3165,3147,3126,3126,3126,3117,3075,3063,3072,3093,3051,3039,3033,2982,2967,2952,2976,2946,2946,2925,2919,2919,2889,2889,2904,2892,2886,2883,2928,2895,2874,2841,2826,2811,2769,2754,2715,2736,2670,2655,2628,2622,2583,2562,2562,2544,2514,2475,2457,2442,2415,2409,2397,2376,2346,2316,2295,2241,2241,2226,2220,2208,2211,2211,2205,2169,2163,2106,2100,2067,2070,2034,1998,2001,1986,1941,1929,1893,1881,1881,1866,1875,1857,1845,1833,1788,1767,1746,1725,1725,1674,1683,1701,1707,1665,1674,1626,1605,1605,1590,1584,1527,1521,1488,1431,1437,1386,1353,1317,1290,1224,1197,1194,1167,1143,1098,1098,1062,1053,1038,1014,999,966,945,915,909,861,810,771,759,705,690,669,642,630,585,585,579,534,507,462,402,366,360,324,303,288,258,228,201,180,168,135,105,69,57];
Test2 = [6,6,6,6,6,6,12,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,24,36,36,36,36,36,36,36,36,48,48,54,54,54,54,54,54,54,60,60,60,60,60,60,60,60,66,66,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,78,84,84,84,84,84,96,96,102,102,102,102,102,102,114,114,114,114,114,114,120,120,120,120,120,120,120,120,126,132,132,138,138,138,138,138,138,144,144,144,144,156,156,168,168,174,174,174,180,180,192,192,192,192,192,204,210,210,210,210,216,222,228,228,234,234,240,240,240,246,252,258,258,258,258,264,276,276,276,276,282,282,282,282,288,294,300,300,300,300,300,300,300,312,318,318,318,318,324,336,336,336,342,348,348,348,348,360,360,360,360,366,366,366,366,390,390,396,396,402,408,426,426,426,426,426,426,426,432,432,432,432,432,432,432,432,438,438,444,444,444,444,444,450,474,480,486,498,498,498,498,504,516,522,522,546,558,558,558,564,570,582,582,582,588,588,594,600,618,618,618,624,630,630,630,642,660,660,660,660,660,666,672,672,672,690,690,690,696,708,708,708,708,714,726,738,744,744,744,744,750,756,762,762,768,774,774,780,780,780,780,798,798,804,810,822,834,840,852,852,864,864,882,888,894,900,900,906,918,924,930,948,954,954,966,981,987,987,987,987,993,1005,1038,1044,1050,1050,1056,1077,1083,1089,1107,1125,1131,1137,1143,1158,1164,1182,1194,1206,1248,1278,1278,1293,1293,1305,1305,1305,1311,1317,1317,1329,1335,1341,1368,1395,1395,1416,1437,1449,1449,1479,1479,1485,1503,1509,1524,1536,1566,1566,1587,1593,1611,1611,1617,1623,1644,1656,1674,1692,1725,1755,1773,1785,1785,1785,1812,1854,1854,1866,1896,1926,1947,1947,1965,1965,2007,2013,2013,2043,2055,2055,2088,2094,2115,2121,2136,2163,2163,2211,2217,2217,2223,2244,2271,2286,2286,2322,2349,2349,2370,2418,2445,2487,2493,2523,2565,2586,2592,2592,2616,2616,2631,2643,2658,2703,2718,2730,2751,2781,2817,2850,2850,2850,2871,2892,2928,2949,2949,2949,3033,3054,3090,3102,3162,3183,3204,3219,3225,3252,3258,3258,3309,3336,3381,3396,3423,3444,3486,3561,3606,3642,3660,3720,3720,3738,3798,3813,3876,3882,3888,3918,3960,4008,4032,4071,4152,4170,4215,4221,4257,4308,4380,4362,4413,4353,4404,4392,4368,4368,4356,4335,4356,4362,4401,4398,4416,4425,4404,4386,4428,4428,4386,4392,4380,4335,4284,4305,4263,4263,4272,4293,4299,4305,4299,4293,4257,4269,4257,4308,4308,4332,4323,4323,4344,4338,4359,4329,4377,4323,4311,4305,4254,4275,4266,4260,4266,4230,4218,4218,4245,4281,4329,4341,4314,4365,4332,4281,4296,4323,4326,4356,4350,4356,4350,4356,4386,4401,4392,4392,4377,4371,4353,4353,4338,4293,4275,4239,4260,4200,4179,4149,4167,4194,4185,4185,4194,4182,4140,4152,4140,4167,4131,4110,4107,4062,4062,4101,4050,4023,4044,4032,4035,4032,4008,3984,3999,3984,4005,3984,3999,4014,4008,3954,3996,4008,4014,4062,4050,4059,4050,4062,4041,4020,4056,4026,4062,4044,4035,4014,4026,4029,4029,4032,4086,4095,4062,4074,4068,4083,4062,4059,4041,4029,4050,4083,4113,4152,4176,4161,4101,4086,4044,4011,4008,3993,4002,4020,4029,4002,4029,4032,4026,4008,4023,4032,4038,4065,4092,4083,4077,4050,4035,3987,3951,3939,3987,3972,3966,3930,3918,3882,3903,3939,3927,3951,3930,3891,3900,3918,3879,3864,3882,3870,3894,3888,3927,3960,3969,3975,3960,3975,3954,3963,3948,4008,3966,3927,3945,3897,3870,3819,3855,3891,3876,3873,3867,3864,3879,3828,3813,3828,3789,3774,3738,3693,3714,3729,3705,3699,3699,3687,3675,3648,3645,3630,3576,3591,3576,3576,3594,3621,3675,3624,3645,3669,3657,3642,3615,3678,3723,3738,3747,3720,3705,3705,3762,3732,3726,3726,3705,3684,3687,3675,3720,3723,3714,3654,3606,3636,3654,3672,3723,3693,3711,3663,3684,3696,3690,3720,3714,3708,3687,3672,3702,3705,3684,3720,3690,3648,3669,3720,3705,3678,3651,3648,3648,3609,3585,3525,3474,3492,3495,3414,3381,3372,3429,3438,3459,3423,3423,3402,3378,3348,3399,3408,3414,3423,3447,3450,3471,3483,3492,3528,3498,3456,3465,3414,3354,3342,3306,3300,3294,3273,3243,3225,3198,3180,3180,3174,3180,3180,3156,3156,3099,3078,3042,3024,3003,2991,2976,2961,2904,2916,2919,2871,2814,2793,2769,2763,2742,2730,2676,2697,2697,2616,2565,2553,2553,2511,2484,2478,2472,2496,2469,2448,2421,2427,2442,2421,2436,2451,2418,2349,2346,2367,2337,2352,2358,2286,2271,2286,2223,2208,2208,2187,2145,2175,2190,2208,2208,2202,2187,2193,2166,2130,2103,2034,1995,2004,1968,1977,1926,1914,1887,1863,1845,1851,1791,1749,1734,1716,1716,1695,1692,1656,1644,1623,1566,1509,1458,1464,1449,1449,1455,1416,1410,1374,1344,1302,1281,1269,1269,1257,1215,1188,1158,1146,1140,1107,1083,1041,1014,1008,990,954,921,912,870,864,813,807,780,774,768,744,744,696,660,660,669,657,621,606,582,576,549,516,495,477,426,396,411,324,279,252,237,222,168,96,75,36];
Test3 = [6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,18,18,18,18,18,18,18,18,24,24,24,24,24,30,36,36,36,36,36,36,36,36,36,36,36,42,42,42,42,48,48,48,48,48,54,54,54,54,54,54,54,54,54,54,54,54,54,54,60,60,60,66,72,72,72,72,72,72,78,78,84,84,84,96,96,96,108,108,114,120,120,120,120,120,120,120,126,126,126,126,138,138,138,138,144,150,162,162,162,162,174,174,180,180,186,186,186,186,192,198,204,210,210,210,210,216,216,216,216,222,222,222,222,228,228,228,228,228,228,228,240,246,252,264,270,276,282,282,282,282,300,306,306,312,312,324,324,330,330,330,330,330,330,336,336,336,354,360,366,366,366,372,372,372,372,372,372,378,378,378,378,378,384,396,396,408,420,420,426,432,438,438,438,438,438,444,444,450,456,468,480,492,492,492,498,498,504,504,504,504,510,516,516,522,534,540,546,546,546,546,546,552,552,564,570,582,588,588,588,594,594,594,594,594,594,618,624,642,654,654,654,666,666,666,666,678,678,678,678,684,690,690,690,690,690,696,702,708,720,738,738,753,771,777,783,798,804,810,825,825,825,825,831,831,843,849,876,876,882,882,882,882,888,903,918,918,918,936,942,957,969,984,996,1002,1014,1056,1077,1083,1098,1110,1122,1128,1143,1158,1158,1164,1164,1164,1170,1176,1176,1182,1188,1188,1188,1209,1242,1257,1272,1278,1293,1314,1341,1341,1341,1353,1353,1383,1404,1404,1410,1425,1440,1452,1473,1488,1515,1551,1566,1566,1587,1626,1653,1680,1680,1695,1716,1752,1788,1833,1854,1878,1884,1899,1932,1944,1971,1971,1983,2004,2058,2085,2121,2139,2145,2160,2172,2184,2211,2229,2256,2262,2268,2295,2307,2343,2364,2379,2400,2433,2475,2490,2517,2562,2583,2589,2604,2604,2622,2658,2664,2727,2760,2790,2811,2850,2880,2901,2967,2997,3027,3066,3099,3111,3117,3135,3156,3162,3198,3213,3240,3276,3291,3306,3336,3342,3360,3375,3390,3402,3414,3420,3426,3447,3468,3498,3504,3537,3597,3630,3651,3687,3708,3729,3759,3789,3825,3870,3903,3903,3915,3942,3990,4026,4068,4104,4176,4197,4248,4302,4314,4278,4296,4260,4275,4281,4263,4269,4296,4326,4326,4362,4362,4338,4323,4329,4341,4356,4377,4368,4386,4407,4413,4428,4398,4413,4392,4314,4302,4323,4338,4317,4311,4281,4260,4284,4260,4278,4224,4275,4269,4260,4275,4296,4287,4263,4290,4278,4266,4269,4260,4260,4284,4281,4281,4341,4341,4350,4377,4353,4347,4293,4293,4338,4329,4302,4302,4356,4377,4362,4338,4311,4302,4305,4326,4341,4347,4332,4365,4335,4353,4350,4365,4338,4344,4362,4320,4344,4329,4299,4299,4323,4386,4362,4377,4392,4407,4365,4338,4329,4395,4386,4392,4431,4407,4368,4359,4353,4320,4302,4314,4323,4290,4335,4341,4269,4284,4308,4320,4314,4302,4290,4320,4320,4317,4302,4242,4224,4209,4230,4269,4269,4281,4284,4260,4257,4254,4260,4275,4248,4257,4275,4281,4260,4230,4269,4299,4299,4308,4293,4419,4407,4380,4401,4377,4407,4401,4410,4374,4359,4314,4341,4368,4368,4371,4335,4371,4356,4335,4350,4350,4362,4362,4356,4350,4368,4383,4353,4368,4359,4344,4380,4401,4395,4299,4287,4254,4233,4182,4191,4206,4170,4104,4068,4068,4077,4038,4053,4041,4050,4071,4062,4086,4065,4107,4107,4077,4056,3999,3999,3987,3990,3999,4005,3990,3990,3996,3978,3987,3975,3978,4014,4014,3984,3948,3903,3858,3861,3891,3867,3891,3951,3996,3948,3972,3981,3960,4038,4017,4002,4032,4017,4011,3996,4023,4023,4122,4092,4077,4050,3999,3984,3972,3951,3969,4017,4014,4005,4011,4005,4032,4026,4011,3966,3930,3939,3939,3924,3903,3924,3888,3879,3828,3777,3750,3801,3801,3750,3771,3759,3753,3792,3774,3765,3729,3714,3729,3735,3789,3768,3726,3741,3720,3672,3681,3684,3720,3720,3753,3744,3765,3765,3759,3723,3663,3639,3654,3639,3657,3639,3630,3624,3654,3666,3639,3627,3642,3594,3597,3540,3519,3519,3537,3504,3513,3507,3486,3465,3471,3456,3459,3423,3453,3447,3486,3450,3420,3468,3477,3486,3480,3465,3408,3414,3417,3396,3363,3378,3315,3315,3309,3288,3252,3213,3162,3171,3171,3144,3168,3123,3081,3027,3027,2994,3012,2994,3015,3018,3000,3018,3033,3024,2967,2934,2922,2919,2904,2889,2832,2787,2706,2670,2664,2628,2637,2586,2586,2595,2577,2577,2556,2550,2514,2517,2505,2514,2511,2496,2448,2382,2346,2313,2313,2340,2304,2277,2235,2217,2145,2139,2103,2073,2079,2043,2007,2007,1959,1953,1923,1863,1839,1806,1785,1728,1713,1716,1680,1635,1644,1638,1617,1626,1626,1620,1614,1602,1602,1572,1542,1536,1500,1464,1473,1446,1416,1431,1431,1440,1389,1398,1371,1362,1371,1356,1350,1320,1263,1257,1233,1233,1206,1221,1179,1152,1116,1116,1059,1068,1005,987,981,981,954,921,879,849,819,792,756,729,708,666,666,624,573,513,474,447,426,420,393,372,321,300,243,228,192,180,135,75,54];
Test array as first row, Test2 as 2nd row, Test3 array as 3rd row

採用された回答

Jan
Jan 2022 年 6 月 24 日
A matrix is a rectangular list of elments. This means, that all rows must have the same number of elements.
Either fill the shorter rows with NaNs:
Test = [6,7,8];
Test2 = [1,2,3,4,5];
Test3 = [2,4];
Width = max([numel(Test), numel(Test2), numel(Test3)]);
M = NaN(3, Width);
M(1, 1:numel(Test)) = Test;
M(2, 1:numel(Test2)) = Test2;
M(3, 1:numel(Test3)) = Test3;
M
M = 3×5
6 7 8 NaN NaN 1 2 3 4 5 2 4 NaN NaN NaN
Or use a cell matrix:
C = {Test; Test2; Test3}

その他の回答 (2 件)

Voss
Voss 2022 年 6 月 24 日
Since the vectors are of differing lengths, the resulting matrix will have to have some values fill out the remaining elements in all but the longest row; I'll fill it out with NaNs.
Test = [6,6,6,6,6,6,6,6,6,6,6,6,12,12,12,12,12,18,18,18,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,30,30,36,36,36,36,36,36,36,36,36,42,42,42,42,48,48,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,60,60,66,66,66,66,66,66,66,66,66,72,72,78,78,78,84,84,84,84,84,90,90,102,120,120,126,126,132,132,138,138,138,150,156,156,156,168,180,180,180,180,180,180,186,192,192,198,198,204,204,204,204,210,210,210,210,210,210,210,210,216,216,222,228,228,228,228,228,234,234,234,240,246,246,252,258,282,282,282,282,282,282,282,282,282,294,294,294,300,300,306,312,312,318,318,318,324,324,330,330,330,330,330,330,330,348,360,360,360,360,360,366,366,366,366,366,372,378,396,396,402,408,408,408,414,414,420,420,420,420,426,426,432,432,450,456,462,468,468,468,474,480,480,480,492,492,492,492,492,498,516,516,522,534,534,540,552,558,558,558,564,582,600,600,600,606,612,618,618,624,630,630,636,642,648,654,654,654,654,672,678,696,696,702,714,720,726,738,744,750,750,756,762,774,780,792,798,798,804,816,816,834,840,846,852,852,870,870,870,882,900,912,912,912,912,912,912,912,918,930,936,942,954,960,960,966,978,984,999,1014,1020,1032,1032,1044,1059,1071,1077,1083,1125,1137,1149,1149,1155,1167,1191,1197,1197,1203,1209,1224,1224,1245,1260,1266,1308,1314,1314,1347,1353,1365,1380,1416,1422,1437,1464,1464,1470,1485,1512,1518,1536,1542,1575,1581,1602,1602,1614,1626,1656,1656,1686,1728,1770,1785,1791,1806,1842,1854,1881,1881,1881,1923,1923,1935,1965,1965,1971,1983,1983,1995,2013,2013,2013,2025,2031,2052,2073,2118,2133,2151,2214,2244,2286,2307,2328,2334,2361,2391,2397,2403,2403,2409,2424,2430,2430,2466,2481,2532,2538,2568,2568,2574,2598,2604,2625,2658,2709,2715,2730,2772,2778,2823,2850,2871,2886,2913,2949,3021,3042,3042,3108,3144,3177,3219,3270,3291,3309,3336,3363,3399,3435,3471,3510,3540,3540,3576,3609,3645,3678,3699,3714,3726,3741,3804,3831,3867,3873,3888,3915,3936,3963,4005,4038,4053,4074,4074,4080,4086,4086,4092,4092,4098,4122,4137,4224,4254,4275,4320,4326,4347,4374,4419,4452,4443,4449,4464,4434,4440,4404,4371,4401,4407,4422,4422,4470,4494,4503,4485,4506,4515,4515,4491,4503,4491,4425,4476,4491,4512,4518,4503,4491,4503,4548,4614,4593,4623,4572,4578,4572,4587,4593,4590,4605,4605,4659,4668,4722,4716,4701,4710,4686,4659,4614,4572,4581,4590,4596,4596,4602,4608,4596,4650,4635,4644,4623,4608,4608,4641,4647,4617,4626,4641,4665,4614,4605,4596,4593,4617,4614,4629,4629,4617,4626,4617,4587,4572,4491,4482,4452,4446,4407,4419,4431,4476,4425,4416,4422,4440,4434,4449,4392,4416,4383,4383,4407,4350,4377,4386,4371,4371,4371,4284,4290,4275,4305,4293,4296,4293,4317,4284,4275,4251,4251,4287,4302,4311,4314,4266,4275,4233,4221,4230,4191,4146,4098,4113,4128,4182,4110,4104,4110,4146,4155,4182,4197,4191,4266,4215,4212,4224,4230,4245,4245,4263,4299,4272,4302,4302,4323,4317,4347,4317,4311,4323,4317,4287,4302,4272,4287,4254,4263,4275,4233,4272,4257,4197,4191,4155,4119,4164,4218,4209,4197,4176,4191,4140,4131,4119,4059,3999,4014,4020,4014,4002,3993,3981,3996,3981,3987,3960,3954,3981,3969,3993,3966,3966,3990,4014,3999,3993,3963,3948,3948,3945,3960,3948,3936,4002,4011,3990,4005,4020,4029,4047,3981,3936,3951,3966,3951,3942,3891,3825,3861,3849,3849,3849,3840,3750,3714,3741,3765,3786,3786,3756,3714,3702,3702,3708,3684,3684,3681,3708,3744,3738,3702,3696,3696,3696,3669,3666,3630,3615,3624,3591,3612,3612,3642,3597,3600,3624,3633,3642,3624,3639,3618,3633,3621,3609,3546,3534,3540,3555,3537,3534,3513,3552,3546,3516,3477,3507,3531,3564,3558,3507,3552,3528,3528,3534,3543,3540,3525,3507,3492,3513,3480,3399,3357,3393,3363,3342,3363,3348,3339,3333,3333,3327,3378,3333,3375,3348,3348,3357,3336,3348,3348,3327,3312,3306,3309,3288,3279,3300,3258,3282,3234,3234,3228,3252,3237,3222,3210,3189,3189,3174,3150,3165,3180,3165,3147,3126,3126,3126,3117,3075,3063,3072,3093,3051,3039,3033,2982,2967,2952,2976,2946,2946,2925,2919,2919,2889,2889,2904,2892,2886,2883,2928,2895,2874,2841,2826,2811,2769,2754,2715,2736,2670,2655,2628,2622,2583,2562,2562,2544,2514,2475,2457,2442,2415,2409,2397,2376,2346,2316,2295,2241,2241,2226,2220,2208,2211,2211,2205,2169,2163,2106,2100,2067,2070,2034,1998,2001,1986,1941,1929,1893,1881,1881,1866,1875,1857,1845,1833,1788,1767,1746,1725,1725,1674,1683,1701,1707,1665,1674,1626,1605,1605,1590,1584,1527,1521,1488,1431,1437,1386,1353,1317,1290,1224,1197,1194,1167,1143,1098,1098,1062,1053,1038,1014,999,966,945,915,909,861,810,771,759,705,690,669,642,630,585,585,579,534,507,462,402,366,360,324,303,288,258,228,201,180,168,135,105,69,57];
Test2 = [6,6,6,6,6,6,12,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,24,36,36,36,36,36,36,36,36,48,48,54,54,54,54,54,54,54,60,60,60,60,60,60,60,60,66,66,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,78,84,84,84,84,84,96,96,102,102,102,102,102,102,114,114,114,114,114,114,120,120,120,120,120,120,120,120,126,132,132,138,138,138,138,138,138,144,144,144,144,156,156,168,168,174,174,174,180,180,192,192,192,192,192,204,210,210,210,210,216,222,228,228,234,234,240,240,240,246,252,258,258,258,258,264,276,276,276,276,282,282,282,282,288,294,300,300,300,300,300,300,300,312,318,318,318,318,324,336,336,336,342,348,348,348,348,360,360,360,360,366,366,366,366,390,390,396,396,402,408,426,426,426,426,426,426,426,432,432,432,432,432,432,432,432,438,438,444,444,444,444,444,450,474,480,486,498,498,498,498,504,516,522,522,546,558,558,558,564,570,582,582,582,588,588,594,600,618,618,618,624,630,630,630,642,660,660,660,660,660,666,672,672,672,690,690,690,696,708,708,708,708,714,726,738,744,744,744,744,750,756,762,762,768,774,774,780,780,780,780,798,798,804,810,822,834,840,852,852,864,864,882,888,894,900,900,906,918,924,930,948,954,954,966,981,987,987,987,987,993,1005,1038,1044,1050,1050,1056,1077,1083,1089,1107,1125,1131,1137,1143,1158,1164,1182,1194,1206,1248,1278,1278,1293,1293,1305,1305,1305,1311,1317,1317,1329,1335,1341,1368,1395,1395,1416,1437,1449,1449,1479,1479,1485,1503,1509,1524,1536,1566,1566,1587,1593,1611,1611,1617,1623,1644,1656,1674,1692,1725,1755,1773,1785,1785,1785,1812,1854,1854,1866,1896,1926,1947,1947,1965,1965,2007,2013,2013,2043,2055,2055,2088,2094,2115,2121,2136,2163,2163,2211,2217,2217,2223,2244,2271,2286,2286,2322,2349,2349,2370,2418,2445,2487,2493,2523,2565,2586,2592,2592,2616,2616,2631,2643,2658,2703,2718,2730,2751,2781,2817,2850,2850,2850,2871,2892,2928,2949,2949,2949,3033,3054,3090,3102,3162,3183,3204,3219,3225,3252,3258,3258,3309,3336,3381,3396,3423,3444,3486,3561,3606,3642,3660,3720,3720,3738,3798,3813,3876,3882,3888,3918,3960,4008,4032,4071,4152,4170,4215,4221,4257,4308,4380,4362,4413,4353,4404,4392,4368,4368,4356,4335,4356,4362,4401,4398,4416,4425,4404,4386,4428,4428,4386,4392,4380,4335,4284,4305,4263,4263,4272,4293,4299,4305,4299,4293,4257,4269,4257,4308,4308,4332,4323,4323,4344,4338,4359,4329,4377,4323,4311,4305,4254,4275,4266,4260,4266,4230,4218,4218,4245,4281,4329,4341,4314,4365,4332,4281,4296,4323,4326,4356,4350,4356,4350,4356,4386,4401,4392,4392,4377,4371,4353,4353,4338,4293,4275,4239,4260,4200,4179,4149,4167,4194,4185,4185,4194,4182,4140,4152,4140,4167,4131,4110,4107,4062,4062,4101,4050,4023,4044,4032,4035,4032,4008,3984,3999,3984,4005,3984,3999,4014,4008,3954,3996,4008,4014,4062,4050,4059,4050,4062,4041,4020,4056,4026,4062,4044,4035,4014,4026,4029,4029,4032,4086,4095,4062,4074,4068,4083,4062,4059,4041,4029,4050,4083,4113,4152,4176,4161,4101,4086,4044,4011,4008,3993,4002,4020,4029,4002,4029,4032,4026,4008,4023,4032,4038,4065,4092,4083,4077,4050,4035,3987,3951,3939,3987,3972,3966,3930,3918,3882,3903,3939,3927,3951,3930,3891,3900,3918,3879,3864,3882,3870,3894,3888,3927,3960,3969,3975,3960,3975,3954,3963,3948,4008,3966,3927,3945,3897,3870,3819,3855,3891,3876,3873,3867,3864,3879,3828,3813,3828,3789,3774,3738,3693,3714,3729,3705,3699,3699,3687,3675,3648,3645,3630,3576,3591,3576,3576,3594,3621,3675,3624,3645,3669,3657,3642,3615,3678,3723,3738,3747,3720,3705,3705,3762,3732,3726,3726,3705,3684,3687,3675,3720,3723,3714,3654,3606,3636,3654,3672,3723,3693,3711,3663,3684,3696,3690,3720,3714,3708,3687,3672,3702,3705,3684,3720,3690,3648,3669,3720,3705,3678,3651,3648,3648,3609,3585,3525,3474,3492,3495,3414,3381,3372,3429,3438,3459,3423,3423,3402,3378,3348,3399,3408,3414,3423,3447,3450,3471,3483,3492,3528,3498,3456,3465,3414,3354,3342,3306,3300,3294,3273,3243,3225,3198,3180,3180,3174,3180,3180,3156,3156,3099,3078,3042,3024,3003,2991,2976,2961,2904,2916,2919,2871,2814,2793,2769,2763,2742,2730,2676,2697,2697,2616,2565,2553,2553,2511,2484,2478,2472,2496,2469,2448,2421,2427,2442,2421,2436,2451,2418,2349,2346,2367,2337,2352,2358,2286,2271,2286,2223,2208,2208,2187,2145,2175,2190,2208,2208,2202,2187,2193,2166,2130,2103,2034,1995,2004,1968,1977,1926,1914,1887,1863,1845,1851,1791,1749,1734,1716,1716,1695,1692,1656,1644,1623,1566,1509,1458,1464,1449,1449,1455,1416,1410,1374,1344,1302,1281,1269,1269,1257,1215,1188,1158,1146,1140,1107,1083,1041,1014,1008,990,954,921,912,870,864,813,807,780,774,768,744,744,696,660,660,669,657,621,606,582,576,549,516,495,477,426,396,411,324,279,252,237,222,168,96,75,36];
Test3 = [6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,18,18,18,18,18,18,18,18,24,24,24,24,24,30,36,36,36,36,36,36,36,36,36,36,36,42,42,42,42,48,48,48,48,48,54,54,54,54,54,54,54,54,54,54,54,54,54,54,60,60,60,66,72,72,72,72,72,72,78,78,84,84,84,96,96,96,108,108,114,120,120,120,120,120,120,120,126,126,126,126,138,138,138,138,144,150,162,162,162,162,174,174,180,180,186,186,186,186,192,198,204,210,210,210,210,216,216,216,216,222,222,222,222,228,228,228,228,228,228,228,240,246,252,264,270,276,282,282,282,282,300,306,306,312,312,324,324,330,330,330,330,330,330,336,336,336,354,360,366,366,366,372,372,372,372,372,372,378,378,378,378,378,384,396,396,408,420,420,426,432,438,438,438,438,438,444,444,450,456,468,480,492,492,492,498,498,504,504,504,504,510,516,516,522,534,540,546,546,546,546,546,552,552,564,570,582,588,588,588,594,594,594,594,594,594,618,624,642,654,654,654,666,666,666,666,678,678,678,678,684,690,690,690,690,690,696,702,708,720,738,738,753,771,777,783,798,804,810,825,825,825,825,831,831,843,849,876,876,882,882,882,882,888,903,918,918,918,936,942,957,969,984,996,1002,1014,1056,1077,1083,1098,1110,1122,1128,1143,1158,1158,1164,1164,1164,1170,1176,1176,1182,1188,1188,1188,1209,1242,1257,1272,1278,1293,1314,1341,1341,1341,1353,1353,1383,1404,1404,1410,1425,1440,1452,1473,1488,1515,1551,1566,1566,1587,1626,1653,1680,1680,1695,1716,1752,1788,1833,1854,1878,1884,1899,1932,1944,1971,1971,1983,2004,2058,2085,2121,2139,2145,2160,2172,2184,2211,2229,2256,2262,2268,2295,2307,2343,2364,2379,2400,2433,2475,2490,2517,2562,2583,2589,2604,2604,2622,2658,2664,2727,2760,2790,2811,2850,2880,2901,2967,2997,3027,3066,3099,3111,3117,3135,3156,3162,3198,3213,3240,3276,3291,3306,3336,3342,3360,3375,3390,3402,3414,3420,3426,3447,3468,3498,3504,3537,3597,3630,3651,3687,3708,3729,3759,3789,3825,3870,3903,3903,3915,3942,3990,4026,4068,4104,4176,4197,4248,4302,4314,4278,4296,4260,4275,4281,4263,4269,4296,4326,4326,4362,4362,4338,4323,4329,4341,4356,4377,4368,4386,4407,4413,4428,4398,4413,4392,4314,4302,4323,4338,4317,4311,4281,4260,4284,4260,4278,4224,4275,4269,4260,4275,4296,4287,4263,4290,4278,4266,4269,4260,4260,4284,4281,4281,4341,4341,4350,4377,4353,4347,4293,4293,4338,4329,4302,4302,4356,4377,4362,4338,4311,4302,4305,4326,4341,4347,4332,4365,4335,4353,4350,4365,4338,4344,4362,4320,4344,4329,4299,4299,4323,4386,4362,4377,4392,4407,4365,4338,4329,4395,4386,4392,4431,4407,4368,4359,4353,4320,4302,4314,4323,4290,4335,4341,4269,4284,4308,4320,4314,4302,4290,4320,4320,4317,4302,4242,4224,4209,4230,4269,4269,4281,4284,4260,4257,4254,4260,4275,4248,4257,4275,4281,4260,4230,4269,4299,4299,4308,4293,4419,4407,4380,4401,4377,4407,4401,4410,4374,4359,4314,4341,4368,4368,4371,4335,4371,4356,4335,4350,4350,4362,4362,4356,4350,4368,4383,4353,4368,4359,4344,4380,4401,4395,4299,4287,4254,4233,4182,4191,4206,4170,4104,4068,4068,4077,4038,4053,4041,4050,4071,4062,4086,4065,4107,4107,4077,4056,3999,3999,3987,3990,3999,4005,3990,3990,3996,3978,3987,3975,3978,4014,4014,3984,3948,3903,3858,3861,3891,3867,3891,3951,3996,3948,3972,3981,3960,4038,4017,4002,4032,4017,4011,3996,4023,4023,4122,4092,4077,4050,3999,3984,3972,3951,3969,4017,4014,4005,4011,4005,4032,4026,4011,3966,3930,3939,3939,3924,3903,3924,3888,3879,3828,3777,3750,3801,3801,3750,3771,3759,3753,3792,3774,3765,3729,3714,3729,3735,3789,3768,3726,3741,3720,3672,3681,3684,3720,3720,3753,3744,3765,3765,3759,3723,3663,3639,3654,3639,3657,3639,3630,3624,3654,3666,3639,3627,3642,3594,3597,3540,3519,3519,3537,3504,3513,3507,3486,3465,3471,3456,3459,3423,3453,3447,3486,3450,3420,3468,3477,3486,3480,3465,3408,3414,3417,3396,3363,3378,3315,3315,3309,3288,3252,3213,3162,3171,3171,3144,3168,3123,3081,3027,3027,2994,3012,2994,3015,3018,3000,3018,3033,3024,2967,2934,2922,2919,2904,2889,2832,2787,2706,2670,2664,2628,2637,2586,2586,2595,2577,2577,2556,2550,2514,2517,2505,2514,2511,2496,2448,2382,2346,2313,2313,2340,2304,2277,2235,2217,2145,2139,2103,2073,2079,2043,2007,2007,1959,1953,1923,1863,1839,1806,1785,1728,1713,1716,1680,1635,1644,1638,1617,1626,1626,1620,1614,1602,1602,1572,1542,1536,1500,1464,1473,1446,1416,1431,1431,1440,1389,1398,1371,1362,1371,1356,1350,1320,1263,1257,1233,1233,1206,1221,1179,1152,1116,1116,1059,1068,1005,987,981,981,954,921,879,849,819,792,756,729,708,666,666,624,573,513,474,447,426,420,393,372,321,300,243,228,192,180,135,75,54];
n = numel(Test);
n2 = numel(Test2);
n3 = numel(Test3);
result = NaN(3,max([n n2 n3]));
result(1,1:n) = Test;
result(2,1:n2) = Test2;
result(3,1:n3) = Test3;
disp(result(:,end-9:end)); % look at the last 10 columns of the result
288 258 228 201 180 168 135 105 69 57 324 279 252 237 222 168 96 75 36 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
  2 件のコメント
Marc Daniel
Marc Daniel 2022 年 6 月 24 日
Thanks for the explanation. Really appreciate your help.
Voss
Voss 2022 年 6 月 24 日
You're welcome!

サインインしてコメントする。


Steven Lord
Steven Lord 2022 年 6 月 24 日
Pad. For simplicity I'm assuming the variables you want to concatenate are vectors, but the general idea is the same if you want to concatenate matrices. The pads would just be taller.
x = [1 2 3 4 5];
y = [1 2 3];
nx = length(x); % These aren't necessary but they make the construction of A shorter
ny = length(y);
A = [x, NaN(1, ny-nx);
y, NaN(1, nx-ny)]
A = 2×5
1 2 3 4 5 1 2 3 NaN NaN
If nx is greater than ny, the first row of A will have length nx + 0 (since specifying a negative size in the "build functions" like NaN is treated as 0.) If nx is less than ny the first row will have length nx + (ny-nx) = ny. So the first row will be as long as the longer of x and y. The same argument holds for the second row.
B = [y, NaN(1, nx-ny);
x, NaN(1, ny-nx)]
B = 2×5
1 2 3 NaN NaN 1 2 3 4 5
  1 件のコメント
Marc Daniel
Marc Daniel 2022 年 6 月 24 日
I see. It's the only way to fill up the empty spaces.
Thanks for the explanation.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFeature Detection and Extraction についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by