Creating a matrix from one column

23 Ansichten (letzte 30 Tage)
Piotr
Piotr am 23 Sep. 2022
Kommentiert: Piotr am 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

Akzeptierte Antwort

Davide Masiello
Davide Masiello am 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')

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by