Creating a matrix from one column

23 ビュー (過去 30 日間)
Piotr
Piotr 2022 年 9 月 23 日
コメント済み: Piotr 2022 年 9 月 26 日
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

採用された回答

Davide Masiello
Davide Masiello 2022 年 9 月 23 日
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 件のコメント
Piotr
Piotr 2022 年 9 月 26 日
Thank you Davidem.This is great!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by