Effacer les filtres
Effacer les filtres

How to fill a matrix of known size with data from a row vector

1 vue (au cours des 30 derniers jours)
Nicolò Monaco
Nicolò Monaco le 4 Fév 2022
Modifié(e) : Fangjun Jiang le 4 Fév 2022
I have a row vector ( dimension: 1x171072000) representing per second data for 66 months.
I want to build a matrix with dimension 2592000x66, so that each colums contains data for each month. For example the first column of the matrix must contains vector(1:2592000) and the second column vector(2592001:5184000.
How can I implement this? thank you in advance

Réponses (2)

Fangjun Jiang
Fangjun Jiang le 4 Fév 2022
Modifié(e) : Fangjun Jiang le 4 Fév 2022
reshape()

Voss
Voss le 4 Fév 2022
A = randn(1,171072000)
A = 1×171072000
0.3875 -1.9867 -0.2379 0.1738 0.0990 1.0573 -0.8788 1.4036 -3.6949 0.1900 -0.0567 1.6167 1.6784 -0.1925 -0.4005 -0.3892 0.8510 -0.4445 0.4273 -0.8284 0.8122 -1.1188 1.5828 0.0162 -1.6376 1.4737 0.7082 0.6214 -0.6716 0.6999
B = reshape(A,[],66)
B = 2592000×66
0.3875 -1.3692 0.9710 1.1184 -0.1400 0.4886 1.8350 -0.5145 -2.4965 -0.0625 3.0628 0.4617 -0.0233 1.3546 -2.1346 0.5320 -1.7412 0.8743 -0.7809 0.1577 0.2596 -1.1410 0.5543 0.3521 -1.3561 2.9233 0.1950 -0.6069 -0.9593 0.6087 -1.9867 0.2935 0.5990 1.3330 -0.2093 -0.0355 0.8335 -0.0923 0.9512 0.2460 0.1450 -1.4380 -0.7361 0.3305 -0.0382 -0.8544 0.0036 -0.3293 0.6408 0.1290 0.1475 -0.3567 -0.8266 -0.7657 0.3540 -0.8802 0.3913 1.2270 0.0518 -0.8527 -0.2379 -0.1303 0.6242 -0.9432 -0.2440 -0.4866 0.7084 0.6374 -0.0030 -0.4931 -1.2137 1.7080 0.3712 -0.3124 0.2305 1.2967 -0.2044 -0.8888 -0.6738 2.5090 0.2927 -0.4236 1.8914 -0.6045 -0.9274 -0.9079 2.4966 1.5355 -0.4163 0.7406 0.1738 1.1187 -0.9046 -0.9690 0.7033 0.6652 -1.6156 -0.5211 0.1894 -0.4359 -1.0656 1.5449 -2.1343 -0.2652 0.3721 -0.3095 0.4569 0.0577 0.2565 -0.3711 0.1692 -0.8408 -0.1927 -2.0263 -0.0819 0.1040 -1.0257 0.2481 0.9915 -1.6916 0.0990 -1.1458 1.3158 -0.5638 1.6851 -2.1849 -0.7489 0.0538 0.6014 0.3645 1.3252 0.5119 -0.5372 -1.1119 0.3421 -0.4771 0.3793 0.4533 -0.6377 1.6360 -0.5688 -0.7498 -1.3135 -2.3985 -0.5606 -1.7849 -0.3119 -0.3053 -0.0892 -0.5111 1.0573 1.6427 -0.6530 0.2691 1.2518 0.5644 0.0371 1.1183 1.7318 2.1239 0.0241 0.6996 0.5446 -0.6511 -1.6128 -0.2210 -1.7022 0.2040 0.8570 -1.8349 1.6881 -0.0667 0.5122 -2.2710 -0.2053 1.7887 -2.5509 -0.5626 -1.1287 -0.2476 -0.8788 -0.0270 -1.3102 1.8098 1.8844 -0.9971 -0.2106 2.1487 0.4754 -0.4267 -0.8447 0.8141 0.9215 0.1069 0.1939 -0.0554 1.1703 -1.3961 -0.8005 0.4885 -0.5591 -0.1350 0.1337 0.4191 0.8678 0.3670 0.9646 -0.6997 0.0361 -0.8307 1.4036 -0.5129 1.2829 -0.6057 -1.0464 -0.5065 -1.4943 1.2725 -0.9102 -0.5495 -1.4496 0.0917 -0.9924 -0.7929 -0.7865 -0.0007 -0.7678 -0.7087 -0.1772 -1.3529 -1.7970 -0.0122 1.8184 -0.1958 -1.3763 -0.1554 0.0724 -3.0187 -1.1723 -1.3708 -3.6949 0.5822 0.0433 0.6614 0.5026 -0.7977 -0.3218 1.4018 1.0860 -1.1523 0.9896 -0.0124 -1.0040 -2.7534 0.2100 0.8065 0.7002 1.5609 0.0379 -0.2185 0.0230 0.5448 0.9784 0.8731 0.5252 -1.4438 -0.0815 0.1840 1.0748 -0.4470 0.1900 0.8321 -0.7244 0.9139 0.6005 -0.4086 -0.1653 -0.6962 -1.5189 -1.8276 1.1408 0.4139 0.1925 1.3744 0.3097 0.1423 -1.8553 -0.2173 -0.8898 -1.2154 -0.1432 0.0743 2.3276 0.3756 -0.3507 0.8325 -0.6457 1.9939 -1.2789 -0.4749

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by