Effacer les filtres
Effacer les filtres

Un-concatenate a vector to a matrix

3 vues (au cours des 30 derniers jours)
Andrew MacPhee
Andrew MacPhee le 6 Fév 2023
Lets say I have a 1x100 vector and I want to split it up into a 10x10 matrix. i.e:
vec1 = [100]
mat1 = [1-10;11-20;21-30; ... ;91-100]
is there a simple command for that?

Réponses (2)

Christopher McCausland
Christopher McCausland le 6 Fév 2023
Hi Andrew,
Reshape() can be a good choice for doing so.
Christopher

Image Analyst
Image Analyst le 7 Fév 2023
Try this:
% Define vec1:
vec1 = 100;
% Create mat1:
mat1 = reshape(1:vec1, 10, [])' % Reshape into 10 rows.
mat1 = 10×10
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

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by