Creating a matrix from one column

조회 수: 24 (최근 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 CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by