Creating a matrix from one column

24 vues (au cours des 30 derniers jours)
Piotr
Piotr le 23 Sep 2022
Commenté : Piotr le 26 Sep 2022
Hello,
I have data in one column which has a few thousand rows, from which I would like to create a matrix with the same data in each column, and with the number of columns the same as the number of rows. Later on, I would like to extract it as a csv file. I feel it could be fairly easily to be done but couldn't succeed yet. Thanks in advance for any comments

Réponse acceptée

Davide Masiello
Davide Masiello le 23 Sep 2022
A = rand(1,1000)'
A = 1000×1
0.3433 0.2117 0.2324 0.9507 0.6145 0.0998 0.8159 0.1063 0.1736 0.4148
M = repmat(A,[1 length(A)])
M = 1000×1000
0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.3433 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2117 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.2324 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.9507 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.6145 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.0998 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.8159 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1063 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.1736 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148 0.4148
writematrix(M,'yourfile.csv')
  1 commentaire
Piotr
Piotr le 26 Sep 2022
Thank you Davidem.This is great!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays 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