Creating a matrix from one column

23 visualizaciones (últimos 30 días)
Piotr
Piotr el 23 de Sept. de 2022
Comentada: Piotr el 26 de Sept. de 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

Respuesta aceptada

Davide Masiello
Davide Masiello el 23 de Sept. de 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 comentario
Piotr
Piotr el 26 de Sept. de 2022
Thank you Davidem.This is great!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by