필터 지우기
필터 지우기

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
Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 26일
편집: Azzi Abdelmalek 2013년 9월 26일
Your question is not clear. Is the matrix you want to create always an nx3 size?
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