Creating array from binary sequence, and certainly with the calculation of the dimension

1 次查看(过去 30 天)
I have this sequence:
0 (1) 0 (2) 0 (3) 1 (4) 1 (5) 0 (6) 0 (7) 0 (8) 0 (9) 0 (10) 1 (11) 0 (12)
0 (13) 0 (14) 0 (15) 1 (16) 0 (17) 0 (18) 1 (19) 1 (20).
As I can create an array like this in general, ie can perform instead of substrings of length 3, 4,5,6 .... too long? I have doubt through command for creating the dimension of the matrix, and I want you to believe me automatically. The matrix example is:
0 (18) 1 (19) 1 (20)
0 (15) 0 (17) 1 (19)
0 (12) 0 (15) 0 (18)
0 (9) 0 (13) 0 (17)
0 (6) 1 (11) 1 (16)
0 (3) 0 (9) 0 (15)
  2 个评论
FRANCISCO
FRANCISCO 2013-9-26
I from the first sequence of data, I want to create an array with that order. No nx3 always no, I have posibildad nX4, nX5, nX6 ........ How could I do?

请先登录,再进行评论。

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-9-26
编辑:Azzi Abdelmalek 2013-9-26
A=randi([0 1],1,30); % your array
m=5; % the result will be nx5
n=numel(A);
p=n-m+1:-m:1;
np=numel(p);
B=zeros(np,m);
B(:,1)=p';
mm=m;
for k=2:m
mm=mm-1;
B(:,k)=(n-m+k:-mm:n-m+k-mm*(np-1))';
end
disp(B) % matrix of indices
out=A(B)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by