how can i organize a column vector in a specific rows?

1 visualización (últimos 30 días)
I have a column vector of 1536 x 1, since I can order it in a row every 24 parts, I will make an example with a smaller vector.
1
two
3
4
5
6
7
8
9
10
it should stay like this.
1 2 3 4 5
6 7 8 9 10
but in the case of the original vector it would have to order in the following way.
1 to 24 in a row
25 to 48 in a row
....
1512 to 1536
any help would help a lot thank you very much

Respuesta aceptada

Voss
Voss el 10 de Jun. de 2022
x = (1:1536).';
reshape(x,24,[]).'
ans = 64×24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240

Más respuestas (1)

Image Analyst
Image Analyst el 10 de Jun. de 2022
Editada: Image Analyst el 10 de Jun. de 2022
Try reshape to make a matrix out of an array
v = rand(1536, 1);
m = reshape(v, [], 24) % 24 columns.
m = 64×24
0.2234 0.0266 0.4546 0.4446 0.2686 0.7231 0.9123 0.7557 0.7213 0.9196 0.9560 0.8490 0.0564 0.6462 0.7119 0.1249 0.5817 0.7088 0.1850 0.6196 0.3152 0.2945 0.5937 0.6693 0.0080 0.8734 0.1697 0.2599 0.5579 0.8714 0.0801 0.1888 0.2987 0.5620 0.9315 0.0728 0.5247 0.9900 0.4024 0.8034 0.9985 0.0456 0.4433 0.4265 0.2364 0.5825 0.4675 0.3901 0.2935 0.0124 0.2973 0.6523 0.1363 0.1508 0.8146 0.9524 0.3722 0.8649 0.0418 0.3839 0.8136 0.1818 0.5958 0.2388 0.7698 0.1884 0.6972 0.4595 0.7526 0.0720 0.1843 0.5364 0.5693 0.5570 0.3523 0.2345 0.9162 0.2694 0.7316 0.1351 0.7612 0.1607 0.4155 0.6270 0.8747 0.3910 0.3900 0.4695 0.5126 0.2536 0.5712 0.3851 0.2371 0.8139 0.1964 0.7199 0.4319 0.7597 0.6573 0.2190 0.1344 0.4480 0.8292 0.5994 0.6009 0.8450 0.1484 0.6460 0.4653 0.6241 0.6421 0.0401 0.3109 0.0728 0.9114 0.7933 0.0149 0.2110 0.6800 0.8361 0.5207 0.7881 0.6380 0.7663 0.3290 0.7155 0.0498 0.5514 0.4578 0.2082 0.1510 0.8412 0.0273 0.0483 0.9069 0.2322 0.0641 0.4798 0.9630 0.1868 0.4882 0.5280 0.8035 0.3349 0.5418 0.0258 0.7953 0.1068 0.9827 0.1330 0.4765 0.7516 0.7081 0.2711 0.7220 0.9681 0.7482 0.9649 0.1545 0.9846 0.1984 0.9190 0.9470 0.4579 0.5023 0.8505 0.3484 0.2383 0.8630 0.6416 0.2494 0.8976 0.2141 0.0951 0.1222 0.6331 0.2598 0.2392 0.1893 0.1099 0.3169 0.2871 0.0075 0.2949 0.4532 0.3587 0.5371 0.7069 0.5457 0.9951 0.3806 0.2589 0.6224 0.8693 0.5179 0.3459 0.7514 0.2253 0.8424 0.7999 0.0779 0.6402 0.4996 0.5656 0.1433 0.8437 0.5364 0.8207 0.0596 0.5592 0.7444 0.1034 0.1463 0.1999 0.8297 0.5648 0.4854 0.2283 0.6250 0.0314 0.9874 0.3996 0.6337 0.1131 0.2597 0.2079 0.8492 0.3042 0.8240 0.2458 0.4839 0.9915 0.9092 0.6570 0.3465 0.4608 0.1639 0.5811 0.6114 0.3950
v = rand(1530, 1);
m = reshape(v, [], 10) % 10 colums per row
m = 153×10
0.6970 0.7140 0.1994 0.7470 0.7818 0.0840 0.9479 0.6196 0.3773 0.0460 0.9940 0.5554 0.7864 0.9041 0.9616 0.2637 0.8217 0.3604 0.8278 0.1840 0.7824 0.6281 0.1509 0.1101 0.6910 0.0391 0.1829 0.6200 0.0974 0.3331 0.8092 0.2672 0.3206 0.1802 0.4509 0.2604 0.6747 0.2573 0.4268 0.4635 0.2119 0.6231 0.4791 0.9154 0.1017 0.4470 0.8241 0.5291 0.7304 0.9480 0.4643 0.5726 0.5201 0.4754 0.4729 0.8261 0.0611 0.6694 0.5231 0.9869 0.2698 0.2863 0.0875 0.7648 0.4531 0.9460 0.4085 0.5006 0.9983 0.0923 0.6465 0.3481 0.5509 0.4753 0.7748 0.4507 0.3125 0.8536 0.1236 0.2609 0.2298 0.0184 0.5729 0.6428 0.0937 0.0353 0.1019 0.8819 0.4124 0.5459 0.3522 0.6000 0.9634 0.2834 0.4282 0.7736 0.4738 0.6789 0.5071 0.9514

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by