shawpnik
shawpnik

Reputation: 111

Get sequence data in different column of output matrix

I have a long column (1*1691). I want to extract values of row (1,13,25...) and put the values in column 1 of my output matrix, then I want to extract values of row (2,14,26....) and put the values in column 2 of my output matrix, then row (3,15,27....),.........upto row (12,24,36......) in column 12.

I have generated an idea to do this, which is given below, but in this way I have to write lines for all the rows, which is cumbersome. Can anyone please help. Thanks

data=untitled;
d=zeros(144,12);
for n=1:144
  d(1,n)=data(n,:);
  d(2,n)=data(n+12,:);
  d(3,n)=data(n+24,:);
  d(4,n)=data(n+36,:);
  d(5,n)=data(n+48,:);
  d(6,n)=data(n+60,:);
  d(7,n)=data(n+72,:);
  d(8,n)=data(n+84,:);
  d(9,n)=data(n+96,:);
  d(10,n)=data(n+108,:);
  ....................

end

Upvotes: 2

Views: 177

Answers (1)

fdermishin
fdermishin

Reputation: 3706

d = reshape(data, 12, [])

Does it work for you?

Upvotes: 4

Related Questions