필터 지우기
필터 지우기

help creating array from binary code

조회 수: 1 (최근 30일)
FRANCISCO
FRANCISCO 2013년 9월 25일
I have this sequence with your right numbering indicating the order.
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 would be the code to create the following matrix?
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)

답변 (1개)

Image Analyst
Image Analyst 2013년 9월 25일
편집: Image Analyst 2013년 9월 25일
out = zeros(6,3); % Initialize
% First column
out(:,1) = inputMatrix(18:-3:3,1);
% Second column
out(:,2) = inputMatrix(19:-2:9, 2);
% Third column
out(:,3) = inputMatrix(20:-1:15, 3);
It would be easy to generalize this for different sized input matrix, but you haven't said you need to do that (plus it's easy enough for you to figure out yourself).
  댓글 수: 3
Image Analyst
Image Analyst 2013년 9월 25일
편집: Image Analyst 2013년 9월 25일
Like I said, it's really easy so I'm pretty sure you can do it. This may help:
L = length(inputMatrix);
out(:,1) = inputMatrix(L-2:-3:1,1);
See if you can get the rest. I can't really do it for you because you didn't say what's constant in the output matrix - the number of rows or the number of columns, or if both vary, how you decide on the number of rows and columns.
FRANCISCO
FRANCISCO 2013년 9월 25일
if true % code %s= sequence numbered 1 to 20 n=length(s);
d=3; %in this case is 3, but may be 4, 5, .....
end Now I do not know how to continue because the dimension of the matrix do not match what is calculated in matlab
How to make so that the dimension of the matrix automatically calculates it me?, Ie you enter your order will:
out = zeros (6,3);% Initialize
But this is as it should be to do it automatically?

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by