필터 지우기
필터 지우기

Vertical to horizontal data

조회 수: 2 (최근 30일)
Ana
Ana 2014년 4월 26일
댓글: Ana 2014년 4월 26일
Hello,
I have a column of data with several rows (about 125000).
I want to copy that data, every 62 rows, to separate columns. So I would have from row 1 to 62 in column A, from row 63 to 125 in column B, from row 126 to 188 in column C and so on until there is no more data.
Is there an easy way to do this? Thank you so much in advance! (I'm new in matlab)

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 26일
a=rand(12500,1); % Example
n=numel(a);
ii=mod(-n,62),
a(end+1:end+ii)=nan
out=reshape(a,62,[])
  댓글 수: 1
Ana
Ana 2014년 4월 26일
Works perfectly, thank you so much!!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

the cyclist
the cyclist 2014년 4월 26일
You probably want the reshape() function.
doc reshape
for syntax details.

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014년 4월 26일
As mentioned, you need to reshape the matrix, but for your data size, which is 125000, since it's not a multiply of 62 you need to pad it with (54) zeros and then reshape it
roughly it's gonna be like
data(1,end:end+54) = 0; % adds 54 zeros to the end of data to be multiply of 62
reshape(data,[],62);
I didn't check the code, might have minor problems ;)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by